Title: [167261] trunk
Revision
167261
Author
[email protected]
Date
2014-04-14 12:45:24 -0700 (Mon, 14 Apr 2014)

Log Message

Web Replay: memoize fallback time values for document.lastModified
https://bugs.webkit.org/show_bug.cgi?id=131318

Reviewed by Joseph Pecoraro.

Source/WebCore:
If a document's Last-Modified header can't be found or used, then
document.lastModified is derived from the current system time or
from filesystem data, which is obviously nondeterministic.

It's better to handle this inside Document::lastModified rather than using
MemoizedDOMResult, because only the fallback case is nondeterministic.

Test: http/tests/inspector/replay/document-last-modified-fallback-value.html

* dom/Document.cpp:
(WebCore::Document::lastModified): Save or reuse memoized fallback value.
* replay/WebInputs.json: Add input DocumentLastModifiedDate.

LayoutTests:
* http/tests/inspector/replay/document-last-modified-fallback-value.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (167260 => 167261)


--- trunk/LayoutTests/ChangeLog	2014-04-14 19:11:50 UTC (rev 167260)
+++ trunk/LayoutTests/ChangeLog	2014-04-14 19:45:24 UTC (rev 167261)
@@ -1,3 +1,12 @@
+2014-04-14  Brian J. Burg  <[email protected]>
+
+        Web Replay: memoize fallback time values for document.lastModified
+        https://bugs.webkit.org/show_bug.cgi?id=131318
+
+        Reviewed by Joseph Pecoraro.
+
+        * http/tests/inspector/replay/document-last-modified-fallback-value.html: Added.
+
 2014-04-14  Eduardo Lima Mitev  <[email protected]>
 
         [GTK] Unreviewed GTK gardening.

Added: trunk/LayoutTests/http/tests/inspector/replay/document-last-modified-fallback-value.html (0 => 167261)


--- trunk/LayoutTests/http/tests/inspector/replay/document-last-modified-fallback-value.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/replay/document-last-modified-fallback-value.html	2014-04-14 19:45:24 UTC (rev 167261)
@@ -0,0 +1,33 @@
+<html>
+<head>
+<script type="text/_javascript_" src=""
+<script type="text/_javascript_" src=""
+<script>
+
+function appendFrameWithLastModifiedDate(text) {
+    document.write('<iframe src="" + escape(text) + '"></iframe>');
+}
+
+appendFrameWithLastModifiedDate('');
+
+function dumpNondeterministicState()
+{
+    return Date.parse(frames[0].document.body.textContent);
+}
+
+function test()
+{
+    function statesAreEqual(a, b)
+    {
+        return a === b;
+    }
+
+    InspectorTest.Replay.runSingleSegmentRefTest(statesAreEqual);
+}
+
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests that we can capture and replay nondeterminism in fallback values for document.lastModified</p>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (167260 => 167261)


--- trunk/Source/WebCore/ChangeLog	2014-04-14 19:11:50 UTC (rev 167260)
+++ trunk/Source/WebCore/ChangeLog	2014-04-14 19:45:24 UTC (rev 167261)
@@ -1,3 +1,23 @@
+2014-04-14  Brian J. Burg  <[email protected]>
+
+        Web Replay: memoize fallback time values for document.lastModified
+        https://bugs.webkit.org/show_bug.cgi?id=131318
+
+        Reviewed by Joseph Pecoraro.
+
+        If a document's Last-Modified header can't be found or used, then 
+        document.lastModified is derived from the current system time or
+        from filesystem data, which is obviously nondeterministic.
+
+        It's better to handle this inside Document::lastModified rather than using
+        MemoizedDOMResult, because only the fallback case is nondeterministic.
+
+        Test: http/tests/inspector/replay/document-last-modified-fallback-value.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::lastModified): Save or reuse memoized fallback value.
+        * replay/WebInputs.json: Add input DocumentLastModifiedDate.
+
 2014-04-12  Antti Koivisto  <[email protected]>
 
         Keep secondary tile grid for zoomed-out scale

Modified: trunk/Source/WebCore/dom/Document.cpp (167260 => 167261)


--- trunk/Source/WebCore/dom/Document.cpp	2014-04-14 19:11:50 UTC (rev 167260)
+++ trunk/Source/WebCore/dom/Document.cpp	2014-04-14 19:45:24 UTC (rev 167261)
@@ -220,6 +220,7 @@
 #endif
 
 #if ENABLE(WEB_REPLAY)
+#include "WebReplayInputs.h"
 #include <replay/EmptyInputCursor.h>
 #endif
 
@@ -3891,8 +3892,20 @@
     // FIXME: If this document came from the file system, the HTML5
     // specificiation tells us to read the last modification date from the file
     // system.
-    if (!foundDate)
-        date.setMillisecondsSinceEpochForDateTime(currentTimeMS());
+    if (!foundDate) {
+        double fallbackDate = currentTimeMS();
+#if ENABLE(WEB_REPLAY)
+        InputCursor& cursor = inputCursor();
+        if (cursor.isCapturing())
+            cursor.appendInput<DocumentLastModifiedDate>(fallbackDate);
+        else if (cursor.isReplaying()) {
+            if (DocumentLastModifiedDate* input = cursor.fetchInput<DocumentLastModifiedDate>())
+                fallbackDate = input->fallbackValue();
+        }
+#endif
+        date.setMillisecondsSinceEpochForDateTime(fallbackDate);
+    }
+
     return String::format("%02d/%02d/%04d %02d:%02d:%02d", date.month() + 1, date.monthDay(), date.fullYear(), date.hour(), date.minute(), date.second());
 }
 

Modified: trunk/Source/WebCore/replay/WebInputs.json (167260 => 167261)


--- trunk/Source/WebCore/replay/WebInputs.json	2014-04-14 19:11:50 UTC (rev 167260)
+++ trunk/Source/WebCore/replay/WebInputs.json	2014-04-14 19:45:24 UTC (rev 167261)
@@ -165,6 +165,14 @@
             "members": [ ]
         },
         {
+            "name": "DocumentLastModifiedDate",
+            "description": "A fallback value used for the document's last modified date if the Last-Modified header can't be found or used.",
+            "queue": "SCRIPT_MEMOIZED",
+            "members": [
+                { "name": "fallbackValue", "type": "double" }
+            ]
+        },
+        {
             "name": "EndSegmentSentinel",
             "description": "A sentinel input to signal the end of a segment.",
             "queue": "EVENT_LOOP",
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to