Changeset 126171 in webkit


Ignore:
Timestamp:
Aug 21, 2012 10:42:50 AM (12 years ago)
Author:
scheib@chromium.org
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):

Location:
trunk
Files:
4 added
5 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r126168 r126171  
     12012-08-21  Vincent Scheib  <scheib@chromium.org>
     2
     3        Add parsing logic for allow-pointer-lock to iframe sandbox attribute.
     4        https://bugs.webkit.org/show_bug.cgi?id=94513
     5
     6        Reviewed by Adam Barth.
     7
     8        Pointer lock was previously blocked from all sandboxed iframes.
     9        Parsing the sandbox="allow-pointer-lock" attribute allows pages
     10        to control the feature and enable it in sandboxed iframes.
     11
     12        * http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock-expected.txt: Added.
     13        * http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock.html: Copied from LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html.
     14        * http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock-expected.txt: Added.
     15        * http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock.html: Copied from LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html.
     16        * http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock-expected.txt: Added.
     17        * http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock.html: Copied from LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html.
     18        * http/tests/pointer-lock/iframe-sandboxed.html:
     19        * http/tests/resources/pointer-lock/iframe-allows-inner-iframe.html: Added.
     20        * http/tests/resources/pointer-lock/iframe-common.js:
     21        (window.onmessage):
     22
    1232012-08-21  Pavel Feldman  <pfeldman@chromium.org>
    224
  • trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock.html

    r126170 r126171  
    88<div>
    99  <div id="target1"></div>
    10   <iframe src="../resources/pointer-lock/inner-iframe.html" sandbox="allow-same-origin allow-scripts" onload="doNextStepWithUserGesture()"></iframe>
     10  <iframe src="../resources/pointer-lock/inner-iframe.html" sandbox="allow-pointer-lock allow-scripts" onload="doNextStepWithUserGesture()"></iframe>
    1111</div>
    1212<script>
    13     description("Test sandboxed iframe blocks pointer lock.")
     13    description("Test sandboxed iframe with allow-pointer-lock allows pointer lock.");
    1414    window.jsTestIsAsync = true;
    1515
     
    2222          window.onmessage = function (messageEvent) {
    2323              message = messageEvent.data;
    24               shouldBeEqualToString("message", "inner-iframe.html onwebkitpointerlockerror");
     24              shouldBeEqualToString("message", "inner-iframe.html onwebkitpointerlockchange, document.webkitPointerLockElement = [object HTMLBodyElement]");
    2525              window.onmessage = null;
    2626              doNextStep();
  • trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock.html

    r126170 r126171  
    88<div>
    99  <div id="target1"></div>
    10   <iframe src="../resources/pointer-lock/inner-iframe.html" sandbox="allow-same-origin allow-scripts" onload="doNextStepWithUserGesture()"></iframe>
     10  <iframe src="../resources/pointer-lock/iframe-allows-inner-iframe.html" sandbox="allow-pointer-lock allow-scripts" onload="doNextStepWithUserGesture()"></iframe>
    1111</div>
    1212<script>
    13     description("Test sandboxed iframe blocks pointer lock.")
     13    description("Test nested sandboxed iframes with allow-pointer-lock allow pointer lock.");
    1414    window.jsTestIsAsync = true;
    1515
     
    1919    todo = [
    2020      function () {
    21           iframe.contentWindow.postMessage(["eval", 'document.body.webkitRequestPointerLock()'], "*");
     21          iframe.contentWindow.postMessage(["pass message down", "eval", 'document.body.webkitRequestPointerLock()'], "*");
    2222          window.onmessage = function (messageEvent) {
    2323              message = messageEvent.data;
    24               shouldBeEqualToString("message", "inner-iframe.html onwebkitpointerlockerror");
     24              shouldBeEqualToString("message", "inner-iframe.html onwebkitpointerlockchange, document.webkitPointerLockElement = [object HTMLBodyElement]");
    2525              window.onmessage = null;
    2626              doNextStep();
  • trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock.html

    r126170 r126171  
    88<div>
    99  <div id="target1"></div>
    10   <iframe src="../resources/pointer-lock/inner-iframe.html" sandbox="allow-same-origin allow-scripts" onload="doNextStepWithUserGesture()"></iframe>
     10  <iframe src="../resources/pointer-lock/iframe-allows-inner-iframe.html" sandbox="allow-scripts" onload="doNextStepWithUserGesture()"></iframe>
    1111</div>
    1212<script>
    13     description("Test sandboxed iframe blocks pointer lock.")
     13    description("Test nested sandboxed iframes without and then with allow-pointer-lock disallow pointer lock.");
    1414    window.jsTestIsAsync = true;
    1515
     
    1919    todo = [
    2020      function () {
    21           iframe.contentWindow.postMessage(["eval", 'document.body.webkitRequestPointerLock()'], "*");
     21          iframe.contentWindow.postMessage(["pass message down", "eval", 'document.body.webkitRequestPointerLock()'], "*");
    2222          window.onmessage = function (messageEvent) {
    2323              message = messageEvent.data;
  • trunk/LayoutTests/http/tests/pointer-lock/iframe-sandboxed.html

    r124368 r126171  
    88<div>
    99  <div id="target1"></div>
    10   <iframe src="../resources/pointer-lock/inner-iframe.html" sandbox="allow-same-origin allow-scripts" onload="doNextStepWithUserGesture()"></iframe>
     10  <iframe src="../resources/pointer-lock/inner-iframe.html" sandbox="allow-scripts" onload="doNextStepWithUserGesture()"></iframe>
    1111</div>
    1212<script>
  • trunk/LayoutTests/http/tests/resources/pointer-lock/iframe-common.js

    r124301 r126171  
    99        eval(messageEvent.data[1]);
    1010        break;
     11    case "pass message down":
     12        iframe = document.getElementsByTagName("iframe")[0];
     13        iframe.contentWindow.postMessage(messageEvent.data.slice(1), "*");
     14        break;
     15    default:
     16        // Pass all other messages up to parent.
     17        parent.postMessage(messageEvent.data, "*");
    1118    }
    1219}
  • trunk/Source/WebCore/ChangeLog

    r126170 r126171  
     12012-08-21  Vincent Scheib  <scheib@chromium.org>
     2
     3        Add parsing logic for allow-pointer-lock to iframe sandbox attribute.
     4        https://bugs.webkit.org/show_bug.cgi?id=94513
     5
     6        Reviewed by Adam Barth.
     7
     8        Pointer lock was previously blocked from all sandboxed iframes.
     9        Parsing the sandbox="allow-pointer-lock" attribute allows pages
     10        to control the feature and enable it in sandboxed iframes.
     11
     12        Tests: http/tests/pointer-lock/iframe-sandboxed-allow-pointer-lock.html
     13               http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock.html
     14               http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock.html
     15
     16        * dom/SecurityContext.cpp:
     17        (WebCore::SecurityContext::parseSandboxPolicy):
     18
    1192012-08-21  James Robinson  <jamesr@chromium.org>
    220
  • trunk/Source/WebCore/dom/SecurityContext.cpp

    r119204 r126171  
    113113        else if (equalIgnoringCase(sandboxToken, "allow-popups"))
    114114            flags &= ~SandboxPopups;
     115        else if (equalIgnoringCase(sandboxToken, "allow-pointer-lock"))
     116            flags &= ~SandboxPointerLock;
    115117
    116118        start = end + 1;
Note: See TracChangeset for help on using the changeset viewer.