Changeset 67513 in webkit


Ignore:
Timestamp:
Sep 14, 2010 4:29:38 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-09-14 Adam Barth <abarth@webkit.org>

Reviewed by Darin Adler.

document.lastModified gives no output if the response doesn't have a Last-Modified header
https://bugs.webkit.org/show_bug.cgi?id=8475

Implement document.lastModified as per HTML5.

Tests: http/tests/misc/last-modified-parsing.html

http/tests/misc/no-last-modified.html

  • dom/Document.cpp: (WebCore::Document::lastModified):

2010-09-14 Adam Barth <abarth@webkit.org>

Reviewed by Darin Adler.

document.lastModified gives no output if the response doesn't have a Last-Modified header
https://bugs.webkit.org/show_bug.cgi?id=8475

  • http/tests/misc/last-modified-parsing-expected.txt: Added.
  • http/tests/misc/last-modified-parsing.html: Added.
    • Tests some details of our date parsing and serialization. The serialization format is kind of goofy, but that's what the spec seems to want.
  • http/tests/misc/no-last-modified-expected.txt: Added.
  • http/tests/misc/no-last-modified.html: Added.
    • Test was happens if the server doesn't send a Last-Modified header. We're supposed to use the current date and time.
  • http/tests/resources/last-modified.php: Added.
    • PHP helper script.
Location:
trunk
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r67512 r67513  
     12010-09-14  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        document.lastModified gives no output if the response doesn't have a Last-Modified header
     6        https://bugs.webkit.org/show_bug.cgi?id=8475
     7
     8        * http/tests/misc/last-modified-parsing-expected.txt: Added.
     9        * http/tests/misc/last-modified-parsing.html: Added.
     10            - Tests some details of our date parsing and serialization.  The
     11              serialization format is kind of goofy, but that's what the spec
     12              seems to want.
     13        * http/tests/misc/no-last-modified-expected.txt: Added.
     14        * http/tests/misc/no-last-modified.html: Added.
     15            - Test was happens if the server doesn't send a Last-Modified
     16              header.  We're supposed to use the current date and time.
     17        * http/tests/resources/last-modified.php: Added.
     18            - PHP helper script.
     19
    1202010-09-14  Adam Barth  <abarth@webkit.org>
    221
  • trunk/WebCore/ChangeLog

    r67512 r67513  
     12010-09-14  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        document.lastModified gives no output if the response doesn't have a Last-Modified header
     6        https://bugs.webkit.org/show_bug.cgi?id=8475
     7
     8        Implement document.lastModified as per HTML5.
     9
     10        Tests: http/tests/misc/last-modified-parsing.html
     11               http/tests/misc/no-last-modified.html
     12
     13        * dom/Document.cpp:
     14        (WebCore::Document::lastModified):
     15
    1162010-09-14  Adam Barth  <abarth@webkit.org>
    217
  • trunk/WebCore/dom/Document.cpp

    r67512 r67513  
    4444#include "CookieJar.h"
    4545#include "CustomEvent.h"
     46#include "DateComponents.h"
    4647#include "DOMImplementation.h"
    4748#include "DOMWindow.h"
     
    36123613}
    36133614
     3615// http://www.whatwg.org/specs/web-apps/current-work/#dom-document-lastmodified
    36143616String Document::lastModified() const
    36153617{
    3616     Frame* f = frame();
    3617     if (!f)
    3618         return String();
    3619     DocumentLoader* loader = f->loader()->documentLoader();
    3620     if (!loader)
    3621         return String();
    3622     return loader->response().httpHeaderField("Last-Modified");
     3618    DateComponents date;
     3619    bool foundDate = false;
     3620    if (m_frame) {
     3621        String httpLastModified = m_frame->loader()->documentLoader()->response().httpHeaderField("Last-Modified");
     3622        if (!httpLastModified.isEmpty()) {
     3623            date.setMillisecondsSinceEpochForDateTime(parseDate(httpLastModified));
     3624            foundDate = true;
     3625        }
     3626    }
     3627    // FIXME: If this document came from the file system, the HTML5
     3628    // specificiation tells us to read the last modification date from the file
     3629    // system.
     3630    if (!foundDate)
     3631        date.setMillisecondsSinceEpochForDateTime(currentTimeMS());
     3632    return String::format("%02d/%02d/%04d %02d:%02d:%02d", date.month() + 1, date.monthDay(), date.fullYear(), date.hour(), date.minute(), date.second());
    36233633}
    36243634
Note: See TracChangeset for help on using the changeset viewer.