Web Replay: memoize nondeterministic attributes of the Screen interface
authorburg@cs.washington.edu <burg@cs.washington.edu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Apr 2014 00:22:46 +0000 (00:22 +0000)
committerburg@cs.washington.edu <burg@cs.washington.edu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Apr 2014 00:22:46 +0000 (00:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=131339

Reviewed by Timothy Hatcher.

.:

* ManualTests/inspector/replay-window-screen.html: Added.

Source/WebCore:

The values from the screen interface are nondeterministic. Since we can't
change the physical screen dimensions, instead memoize values of attributes.

Test: ManualTests/inspector/replay-window-screen.html

* page/Screen.idl: Add Nondeterministic attribute.

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

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

index 6accf62..b724a8f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2014-04-08  Brian J. Burg  <burg@cs.washington.edu>
+
+        Web Replay: memoize nondeterministic attributes of the Screen interface
+        https://bugs.webkit.org/show_bug.cgi?id=131339
+
+        Reviewed by Timothy Hatcher.
+
+        * ManualTests/inspector/replay-window-screen.html: Added.
+
 2014-04-08  Martin Robinson  <mrobinson@igalia.com>
 
         [GTK] Remove the WebKitGTK+ WebKit 1 code
diff --git a/ManualTests/inspector/replay-window-screen.html b/ManualTests/inspector/replay-window-screen.html
new file mode 100644 (file)
index 0000000..f56f0b6
--- /dev/null
@@ -0,0 +1,111 @@
+<!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 = {
+             height: window.screen.height,
+             width: window.screen.width,
+             colorDepth: window.screen.colorDepth,
+             pixelDepth: window.screen.pixelDepth,
+             availLeft: window.screen.availLeft,
+             availTop: window.screen.availTop,
+             availHeight: window.screen.availHeight,
+             availWidth: window.screen.availWidth,
+        };
+
+        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 the Screen 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 perform one of the following to change screen state:
+</p>
+<ul>
+    <li>If you have two monitors, move the menu bar from one display to the other.</li>
+    <li>Change the monitor's resolution.</li>
+    <li>Change the monitor's color depth.</li>
+    <li>Move the browser window between monitors with different color depth, size, or pixel ratio.</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.screen Values" onclick="dumpState()" />
+</form>
+<div id="hash"></div>
+<div id="blocks"></div>
+<div id="details"></div>
+</body>
+</html>
index aa89c76..496a0ed 100644 (file)
@@ -1,3 +1,17 @@
+2014-04-08  Brian J. Burg  <burg@cs.washington.edu>
+
+        Web Replay: memoize nondeterministic attributes of the Screen interface
+        https://bugs.webkit.org/show_bug.cgi?id=131339
+
+        Reviewed by Timothy Hatcher.
+
+        The values from the screen interface are nondeterministic. Since we can't
+        change the physical screen dimensions, instead memoize values of attributes.
+
+        Test: ManualTests/inspector/replay-window-screen.html
+
+        * page/Screen.idl: Add Nondeterministic attribute.
+
 2014-04-08  Beth Dakin  <bdakin@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=131408
index 0007343..8448504 100644 (file)
 [
     GenerateIsReachable=ImplFrame,
 ] interface Screen {
-    readonly attribute unsigned long height;
-    readonly attribute unsigned long width;
-    readonly attribute unsigned long colorDepth;
-    readonly attribute unsigned long pixelDepth;
-    readonly attribute long availLeft;
-    readonly attribute long availTop;
-    readonly attribute unsigned long availHeight;
-    readonly attribute unsigned long availWidth;
+    [Nondeterministic] readonly attribute unsigned long height;
+    [Nondeterministic] readonly attribute unsigned long width;
+    [Nondeterministic] readonly attribute unsigned long colorDepth;
+    [Nondeterministic] readonly attribute unsigned long pixelDepth;
+    [Nondeterministic] readonly attribute long availLeft;
+    [Nondeterministic] readonly attribute long availTop;
+    [Nondeterministic] readonly attribute unsigned long availHeight;
+    [Nondeterministic] readonly attribute unsigned long availWidth;
 };