Title: [126171] trunk
Revision
126171
Author
[email protected]
Date
2012-08-21 10:42:50 -0700 (Tue, 21 Aug 2012)

Log Message

Add parsing logic for allow-pointer-lock to iframe sandbox attribute.
https://bugs.webkit.org/show_bug.cgi?id=94513

Reviewed by Adam Barth.

Pointer lock was previously blocked from all sandboxed iframes.
Parsing the sandbox="allow-pointer-lock" attribute allows pages
to control the feature and enable it in sandboxed iframes.

Source/WebCore:

Tests: http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock.html
       http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock.html
       http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock.html

* dom/SecurityContext.cpp:
(WebCore::SecurityContext::parseSandboxPolicy):

LayoutTests:

* http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock-expected.txt: Added.
* http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock.html: Copied from LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html.
* http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock-expected.txt: Added.
* http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock.html: Copied from LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html.
* http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock-expected.txt: Added.
* http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock.html: Copied from LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html.
* http/tests/pointer-lock/iframe-sandboxed.html:
* http/tests/resources/pointer-lock/iframe-allows-inner-iframe.html: Added.
* http/tests/resources/pointer-lock/iframe-common.js:
(window.onmessage):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (126170 => 126171)


--- trunk/LayoutTests/ChangeLog	2012-08-21 17:39:24 UTC (rev 126170)
+++ trunk/LayoutTests/ChangeLog	2012-08-21 17:42:50 UTC (rev 126171)
@@ -1,3 +1,25 @@
+2012-08-21  Vincent Scheib  <[email protected]>
+
+        Add parsing logic for allow-pointer-lock to iframe sandbox attribute.
+        https://bugs.webkit.org/show_bug.cgi?id=94513
+
+        Reviewed by Adam Barth.
+
+        Pointer lock was previously blocked from all sandboxed iframes.
+        Parsing the sandbox="allow-pointer-lock" attribute allows pages
+        to control the feature and enable it in sandboxed iframes.
+
+        * http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock-expected.txt: Added.
+        * http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock.html: Copied from LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html.
+        * http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock-expected.txt: Added.
+        * http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock.html: Copied from LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html.
+        * http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock-expected.txt: Added.
+        * http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock.html: Copied from LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html.
+        * http/tests/pointer-lock/iframe-sandboxed.html:
+        * http/tests/resources/pointer-lock/iframe-allows-inner-iframe.html: Added.
+        * http/tests/resources/pointer-lock/iframe-common.js:
+        (window.onmessage):
+
 2012-08-21  Pavel Feldman  <[email protected]>
 
         Web Inspector: do not use window's eval in InjectedScript

Added: trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock-expected.txt (0 => 126171)


--- trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock-expected.txt	2012-08-21 17:42:50 UTC (rev 126171)
@@ -0,0 +1,10 @@
+Test sandboxed iframe with allow-pointer-lock allows pointer lock.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS message is "inner-iframe.html onwebkitpointerlockchange, document.webkitPointerLockElement = [object HTMLBodyElement]"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock-expected.txt
___________________________________________________________________

Added: svn:eol-style

Copied: trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock.html (from rev 126170, trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html) (0 => 126171)


--- trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock.html	2012-08-21 17:42:50 UTC (rev 126171)
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<div>
+  <div id="target1"></div>
+  <iframe src="" sandbox="allow-pointer-lock allow-scripts" _onload_="doNextStepWithUserGesture()"></iframe>
+</div>
+<script>
+    description("Test sandboxed iframe with allow-pointer-lock allows pointer lock.");
+    window.jsTestIsAsync = true;
+
+    targetDiv1 = document.getElementById("target1");
+    iframe = document.getElementsByTagName("iframe")[0];
+
+    todo = [
+      function () {
+          iframe.contentWindow.postMessage(["eval", 'document.body.webkitRequestPointerLock()'], "*");
+          window._onmessage_ = function (messageEvent) {
+              message = messageEvent.data;
+              shouldBeEqualToString("message", "inner-iframe.html onwebkitpointerlockchange, document.webkitPointerLockElement = [object HTMLBodyElement]");
+              window._onmessage_ = null;
+              doNextStep();
+          }
+      },
+    ];
+    // doNextStep() called by iframe onload handler.
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock-expected.txt (0 => 126171)


--- trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock-expected.txt	2012-08-21 17:42:50 UTC (rev 126171)
@@ -0,0 +1,10 @@
+Test nested sandboxed iframes with allow-pointer-lock allow pointer lock.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS message is "inner-iframe.html onwebkitpointerlockchange, document.webkitPointerLockElement = [object HTMLBodyElement]"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock-expected.txt
___________________________________________________________________

Added: svn:eol-style

Copied: trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock.html (from rev 126170, trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html) (0 => 126171)


--- trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock.html	2012-08-21 17:42:50 UTC (rev 126171)
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<div>
+  <div id="target1"></div>
+  <iframe src="" sandbox="allow-pointer-lock allow-scripts" _onload_="doNextStepWithUserGesture()"></iframe>
+</div>
+<script>
+    description("Test nested sandboxed iframes with allow-pointer-lock allow pointer lock.");
+    window.jsTestIsAsync = true;
+
+    targetDiv1 = document.getElementById("target1");
+    iframe = document.getElementsByTagName("iframe")[0];
+
+    todo = [
+      function () {
+          iframe.contentWindow.postMessage(["pass message down", "eval", 'document.body.webkitRequestPointerLock()'], "*");
+          window._onmessage_ = function (messageEvent) {
+              message = messageEvent.data;
+              shouldBeEqualToString("message", "inner-iframe.html onwebkitpointerlockchange, document.webkitPointerLockElement = [object HTMLBodyElement]");
+              window._onmessage_ = null;
+              doNextStep();
+          }
+      },
+    ];
+    // doNextStep() called by iframe onload handler.
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock-expected.txt (0 => 126171)


--- trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock-expected.txt	2012-08-21 17:42:50 UTC (rev 126171)
@@ -0,0 +1,10 @@
+Test nested sandboxed iframes without and then with allow-pointer-lock disallow pointer lock.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS message is "inner-iframe.html onwebkitpointerlockerror"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock-expected.txt
___________________________________________________________________

Added: svn:eol-style

Copied: trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock.html (from rev 126170, trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html) (0 => 126171)


--- trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock.html	2012-08-21 17:42:50 UTC (rev 126171)
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<div>
+  <div id="target1"></div>
+  <iframe src="" sandbox="allow-scripts" _onload_="doNextStepWithUserGesture()"></iframe>
+</div>
+<script>
+    description("Test nested sandboxed iframes without and then with allow-pointer-lock disallow pointer lock.");
+    window.jsTestIsAsync = true;
+
+    targetDiv1 = document.getElementById("target1");
+    iframe = document.getElementsByTagName("iframe")[0];
+
+    todo = [
+      function () {
+          iframe.contentWindow.postMessage(["pass message down", "eval", 'document.body.webkitRequestPointerLock()'], "*");
+          window._onmessage_ = function (messageEvent) {
+              message = messageEvent.data;
+              shouldBeEqualToString("message", "inner-iframe.html onwebkitpointerlockerror");
+              window._onmessage_ = null;
+              doNextStep();
+          }
+      },
+    ];
+    // doNextStep() called by iframe onload handler.
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html (126170 => 126171)


--- trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html	2012-08-21 17:39:24 UTC (rev 126170)
+++ trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html	2012-08-21 17:42:50 UTC (rev 126171)
@@ -7,7 +7,7 @@
 <body>
 <div>
   <div id="target1"></div>
-  <iframe src="" sandbox="allow-same-origin allow-scripts" _onload_="doNextStepWithUserGesture()"></iframe>
+  <iframe src="" sandbox="allow-scripts" _onload_="doNextStepWithUserGesture()"></iframe>
 </div>
 <script>
     description("Test sandboxed iframe blocks pointer lock.")

Added: trunk/LayoutTests/http/tests/resources/pointer-lock/iframe-allows-inner-iframe.html (0 => 126171)


--- trunk/LayoutTests/http/tests/resources/pointer-lock/iframe-allows-inner-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/resources/pointer-lock/iframe-allows-inner-iframe.html	2012-08-21 17:42:50 UTC (rev 126171)
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+    iframe-allows-inner-iframe.html
+    <iframe src="" sandbox="allow-pointer-lock allow-scripts"></iframe>
+</body>
+</html>
+
Property changes on: trunk/LayoutTests/http/tests/resources/pointer-lock/iframe-allows-inner-iframe.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/LayoutTests/http/tests/resources/pointer-lock/iframe-common.js (126170 => 126171)


--- trunk/LayoutTests/http/tests/resources/pointer-lock/iframe-common.js	2012-08-21 17:39:24 UTC (rev 126170)
+++ trunk/LayoutTests/http/tests/resources/pointer-lock/iframe-common.js	2012-08-21 17:42:50 UTC (rev 126171)
@@ -8,6 +8,13 @@
     case "eval":
         eval(messageEvent.data[1]);
         break;
+    case "pass message down":
+        iframe = document.getElementsByTagName("iframe")[0];
+        iframe.contentWindow.postMessage(messageEvent.data.slice(1), "*");
+        break;
+    default:
+        // Pass all other messages up to parent.
+        parent.postMessage(messageEvent.data, "*");
     }
 }
 

Modified: trunk/Source/WebCore/ChangeLog (126170 => 126171)


--- trunk/Source/WebCore/ChangeLog	2012-08-21 17:39:24 UTC (rev 126170)
+++ trunk/Source/WebCore/ChangeLog	2012-08-21 17:42:50 UTC (rev 126171)
@@ -1,3 +1,21 @@
+2012-08-21  Vincent Scheib  <[email protected]>
+
+        Add parsing logic for allow-pointer-lock to iframe sandbox attribute.
+        https://bugs.webkit.org/show_bug.cgi?id=94513
+
+        Reviewed by Adam Barth.
+
+        Pointer lock was previously blocked from all sandboxed iframes.
+        Parsing the sandbox="allow-pointer-lock" attribute allows pages
+        to control the feature and enable it in sandboxed iframes.
+
+        Tests: http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock.html
+               http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock.html
+               http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock.html
+
+        * dom/SecurityContext.cpp:
+        (WebCore::SecurityContext::parseSandboxPolicy):
+
 2012-08-21  James Robinson  <[email protected]>
 
         Unreviewed, rolling out r126169.

Modified: trunk/Source/WebCore/dom/SecurityContext.cpp (126170 => 126171)


--- trunk/Source/WebCore/dom/SecurityContext.cpp	2012-08-21 17:39:24 UTC (rev 126170)
+++ trunk/Source/WebCore/dom/SecurityContext.cpp	2012-08-21 17:42:50 UTC (rev 126171)
@@ -112,6 +112,8 @@
             flags &= ~SandboxTopNavigation;
         else if (equalIgnoringCase(sandboxToken, "allow-popups"))
             flags &= ~SandboxPopups;
+        else if (equalIgnoringCase(sandboxToken, "allow-pointer-lock"))
+            flags &= ~SandboxPointerLock;
 
         start = end + 1;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to