Web Replay: memoize nondeterministic attributes of the Navigator interface
authorburg@cs.washington.edu <burg@cs.washington.edu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Apr 2014 22:01:04 +0000 (22:01 +0000)
committerburg@cs.washington.edu <burg@cs.washington.edu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Apr 2014 22:01:04 +0000 (22:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=131340

Reviewed by Timothy Hatcher.

.:

* ManualTests/inspector/replay-window-navigator-basic.html: Added.

Source/WebCore:

Most attributes of window.navigator do not change very often, but they
could be easily changed by the user or embedder. So, memoize attribute values.

This change does not include navigator.mimeTypes and navigator.plugins,
which will be handled at a different level. <https://webkit.org/b/131341>

Test: ManualTests/inspector/replay-window-navigator-basic.html

* page/Navigator.idl: Add Nondeterministic attribute.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167157 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
ManualTests/inspector/replay-window-navigator-basic.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/Navigator.idl

index 7eeb077..3dbc41e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2014-04-11  Brian J. Burg  <burg@cs.washington.edu>
+
+        Web Replay: memoize nondeterministic attributes of the Navigator interface
+        https://bugs.webkit.org/show_bug.cgi?id=131340
+
+        Reviewed by Timothy Hatcher.
+
+        * ManualTests/inspector/replay-window-navigator-basic.html: Added.
+
 2014-04-09  Brendan Long  <b.long@cablelabs.com>
 
         [GStreamer] Expose MPEG-TS metadata
diff --git a/ManualTests/inspector/replay-window-navigator-basic.html b/ManualTests/inspector/replay-window-navigator-basic.html
new file mode 100644 (file)
index 0000000..d9eea7b
--- /dev/null
@@ -0,0 +1,114 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+        "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<script src="./resources/crypto-md5.js"></script>
+<script type="text/javascript" language="javascript" charset="utf-8">
+
+    window.dumpedStates = [];
+
+    function dumpState() {
+        obj = {
+            appCodeName: window.navigator.appCodeName,
+            appName: window.navigator.appName,
+            appVersion: window.navigator.appVersion,
+            language: window.navigator.language,
+            userAgent: window.navigator.userAgent,
+            platform: window.navigator.platform,
+            product: window.navigator.product,
+            productSub: window.navigator.productSub,
+            vendor: window.navigator.vendor,
+            vendorSub: window.navigator.vendorSub,
+            cookieEnabled: window.navigator.cookieEnabled,
+            javaEnabled: window.navigator.javaEnabled(),
+        };
+
+        dumpedStates.push(obj);
+
+        var block = createBlock(hex_md5(JSON.stringify(obj)));
+        var blocksContainer = document.getElementById("blocks");
+        blocksContainer.appendChild(block);
+
+        var hashLabel = document.getElementById("hash");
+        hash.textContent = hex_md5(JSON.stringify(dumpedStates));
+
+        appendDetails(obj);
+    }
+
+    function appendDetails(obj) {
+        var detailsContainer = document.getElementById("details");
+        var tableElement = document.createElement("table");
+        for (var key in obj) {
+            var rowElement = document.createElement("tr");
+            var keyElement = document.createElement("td");
+            keyElement.textContent = key;
+            rowElement.appendChild(keyElement);
+            var valueElement = document.createElement("td");
+            valueElement.textContent = obj[key];
+            rowElement.appendChild(valueElement);
+            tableElement.appendChild(rowElement);
+        }
+        detailsContainer.appendChild(tableElement);
+        detailsContainer.appendChild(document.createElement("hr"));
+    }
+
+    function createBlock(hash) {
+        var color = "#" + hash.substr(0,6);
+        var block = document.createElement("span");
+        block.style.backgroundColor = color;
+        return block;
+    }
+
+</script>
+
+<style type="text/css">
+body {
+    max-width: 800px;
+}
+#blocks {
+    display: -webkit-flex;
+    width: 600px;
+    -webkit-flex-flow: row wrap;
+}
+
+table {
+    text-decoration: bold;
+    font-family: monospace;
+}
+
+#blocks > span {
+    width: 20px;
+    height: 20px;
+    border-radius: 10px;
+    font-size: 18px;
+    font-weight: bold;
+    font-family: sans-serif;
+    color: #fff;
+    text-align: center;
+}
+</style>
+</head>
+<body onload="dumpState()">
+<p>This page is a manual test for capture and replay of parts of the Navigator DOM API.</p>
+<p>Below, a block is created for each button press that dumps state. The color is derived from a hash of the state. At the bottom is a cumulative hash of all dumped data.</p>
+<hr/>
+<p>
+To test the replay functionality, open the Web Inspector and start capturing. Then change your browser configuration in one of the following ways to change navigator state:
+</p>
+<ul>
+    <li>Change the default language.</li>
+    <li>Toggle Java or cookies support.</li>
+    <li>Change the user agent string.</li>
+</ul>
+</p>
+Then, stop capturing and replay the recording. The replayed execution should produce the same sequence of blocks. More importantly, the cumulative hash value should be the same at the end of capturing and at the end of any subsequent replays.</p>
+</p>
+<hr/>
+<form>
+<input type="button" value="Dump window.navigator Values" onclick="dumpState()" />
+</form>
+<div id="hash"></div>
+<div id="blocks"></div>
+<div id="details"></div>
+</body>
+</html>
index cc9f723..e3b80ec 100644 (file)
@@ -1,3 +1,20 @@
+2014-04-11  Brian J. Burg  <burg@cs.washington.edu>
+
+        Web Replay: memoize nondeterministic attributes of the Navigator interface
+        https://bugs.webkit.org/show_bug.cgi?id=131340
+
+        Reviewed by Timothy Hatcher.
+
+        Most attributes of window.navigator do not change very often, but they
+        could be easily changed by the user or embedder. So, memoize attribute values.
+
+        This change does not include navigator.mimeTypes and navigator.plugins,
+        which will be handled at a different level. <https://webkit.org/b/131341>
+
+        Test: ManualTests/inspector/replay-window-navigator-basic.html
+
+        * page/Navigator.idl: Add Nondeterministic attribute.
+
 2014-04-10  Jer Noble  <jer.noble@apple.com>
 
         [iOS][WK2] Videos should animate into and out of fullscreen.
index 638d5a5..9e0c5d7 100644 (file)
 [
     GenerateIsReachable=ImplFrame,
 ] interface Navigator {
-    readonly attribute DOMString appCodeName;
-    readonly attribute DOMString appName;
-    readonly attribute DOMString appVersion;
-    readonly attribute DOMString language;
-    readonly attribute DOMString userAgent;
-    readonly attribute DOMString platform;
+    [Nondeterministic] readonly attribute DOMString appCodeName;
+    [Nondeterministic] readonly attribute DOMString appName;
+    [Nondeterministic] readonly attribute DOMString appVersion;
+    [Nondeterministic] readonly attribute DOMString language;
+    [Nondeterministic] readonly attribute DOMString userAgent;
+    [Nondeterministic] readonly attribute DOMString platform;
     readonly attribute DOMPluginArray plugins;
     readonly attribute DOMMimeTypeArray mimeTypes;
-    readonly attribute DOMString product;
-    readonly attribute DOMString productSub;
-    readonly attribute DOMString vendor;
-    readonly attribute DOMString vendorSub;
-    readonly attribute boolean cookieEnabled;
-    boolean javaEnabled();
+    [Nondeterministic] readonly attribute DOMString product;
+    [Nondeterministic] readonly attribute DOMString productSub;
+    [Nondeterministic] readonly attribute DOMString vendor;
+    [Nondeterministic] readonly attribute DOMString vendorSub;
+    [Nondeterministic] readonly attribute boolean cookieEnabled;
+    [Nondeterministic] boolean javaEnabled();
 
     readonly attribute boolean onLine;