Title: [218000] trunk
Revision
218000
Author
[email protected]
Date
2017-06-09 10:59:18 -0700 (Fri, 09 Jun 2017)

Log Message

Add flag allow-popups-to-escape-sandbox to iframe sandbox
https://bugs.webkit.org/show_bug.cgi?id=158875

Patch by Frederic Wang <[email protected]> on 2017-06-09
Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

Update expected results for iframe popup escaping tests.

* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1-expected.txt: This test passes.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2-expected.txt: This test passes.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3-expected.txt: Remove error message from text expectation.

Source/WebCore:

This patch adds support for the iframe@allow-popups-to-escape-sandbox attribute.
This allows to pass more W3C Web Platform tests.

Tests: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html
       imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html

* dom/SecurityContext.cpp: Add allow-popups-to-escape-sandbox flag.
(WebCore::SecurityContext::isSupportedSandboxPolicy):
(WebCore::SecurityContext::parseSandboxPolicy):
* dom/SecurityContext.h: Ditto.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::continueLoadAfterNewWindowPolicy): Do not force sandbox flags when we have allow-popups-to-escape-sandbox.
(WebCore::createWindow): Ditto.

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (217999 => 218000)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-06-09 17:57:06 UTC (rev 217999)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-06-09 17:59:18 UTC (rev 218000)
@@ -1,3 +1,16 @@
+2017-06-09  Frederic Wang  <[email protected]>
+
+        Add flag allow-popups-to-escape-sandbox to iframe sandbox
+        https://bugs.webkit.org/show_bug.cgi?id=158875
+
+        Reviewed by Chris Dumez.
+
+        Update expected results for iframe popup escaping tests.
+
+        * web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1-expected.txt: This test passes.
+        * web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2-expected.txt: This test passes.
+        * web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3-expected.txt: Remove error message from text expectation.
+
 2017-06-09  Zan Dobersek  <[email protected]>
 
         [WPE] Enable ENCRYPTED_MEDIA for build-webkit builds

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1-expected.txt (217999 => 218000)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1-expected.txt	2017-06-09 17:57:06 UTC (rev 217999)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1-expected.txt	2017-06-09 17:59:18 UTC (rev 218000)
@@ -1,6 +1,5 @@
-CONSOLE MESSAGE: line 7: Error while parsing the 'sandbox' attribute: 'allow-popups-to-escape-sandbox' is an invalid sandbox flag.
 
 
-FAIL Check that popups from a sandboxed iframe escape the sandbox if
-       allow-popups-to-escape-sandbox is used assert_equals: Should have escaped the sandbox expected "http://localhost:8800" but got "null"
+PASS Check that popups from a sandboxed iframe escape the sandbox if
+       allow-popups-to-escape-sandbox is used 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2-expected.txt (217999 => 218000)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2-expected.txt	2017-06-09 17:57:06 UTC (rev 217999)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2-expected.txt	2017-06-09 17:59:18 UTC (rev 218000)
@@ -1,6 +1,5 @@
-CONSOLE MESSAGE: line 7: Error while parsing the 'sandbox' attribute: 'allow-popups-to-escape-sandbox' is an invalid sandbox flag.
 
 
-FAIL Check that popups from a sandboxed iframe escape the sandbox if
-       allow-popups-to-escape-sandbox is used assert_equals: Should have escaped the sandbox expected "http://localhost:8800" but got "null"
+PASS Check that popups from a sandboxed iframe escape the sandbox if
+       allow-popups-to-escape-sandbox is used 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3-expected.txt (217999 => 218000)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3-expected.txt	2017-06-09 17:57:06 UTC (rev 217999)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3-expected.txt	2017-06-09 17:59:18 UTC (rev 218000)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: line 7: Error while parsing the 'sandbox' attribute: 'allow-popups-to-escape-sandbox' is an invalid sandbox flag.
 CONSOLE MESSAGE: line 15: Unsafe _javascript_ attempt to initiate navigation for frame with URL 'about:blank' from frame with URL 'http://localhost:8800/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-3.html'. The frame attempting navigation is sandboxed, and is therefore disallowed from navigating its ancestors.
 
 

Modified: trunk/Source/WebCore/ChangeLog (217999 => 218000)


--- trunk/Source/WebCore/ChangeLog	2017-06-09 17:57:06 UTC (rev 217999)
+++ trunk/Source/WebCore/ChangeLog	2017-06-09 17:59:18 UTC (rev 218000)
@@ -1,3 +1,24 @@
+2017-06-09  Frederic Wang  <[email protected]>
+
+        Add flag allow-popups-to-escape-sandbox to iframe sandbox
+        https://bugs.webkit.org/show_bug.cgi?id=158875
+
+        Reviewed by Chris Dumez.
+
+        This patch adds support for the iframe@allow-popups-to-escape-sandbox attribute.
+        This allows to pass more W3C Web Platform tests.
+
+        Tests: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html
+               imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html
+
+        * dom/SecurityContext.cpp: Add allow-popups-to-escape-sandbox flag.
+        (WebCore::SecurityContext::isSupportedSandboxPolicy):
+        (WebCore::SecurityContext::parseSandboxPolicy):
+        * dom/SecurityContext.h: Ditto.
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy): Do not force sandbox flags when we have allow-popups-to-escape-sandbox.
+        (WebCore::createWindow): Ditto.
+
 2017-06-09  Jer Noble  <[email protected]>
 
         [iOS] Video occasionally mixes with other system audio instead of interrupting

Modified: trunk/Source/WebCore/dom/SecurityContext.cpp (217999 => 218000)


--- trunk/Source/WebCore/dom/SecurityContext.cpp	2017-06-09 17:57:06 UTC (rev 217999)
+++ trunk/Source/WebCore/dom/SecurityContext.cpp	2017-06-09 17:59:18 UTC (rev 218000)
@@ -86,7 +86,7 @@
 bool SecurityContext::isSupportedSandboxPolicy(StringView policy)
 {
     static const char* const supportedPolicies[] = {
-        "allow-forms", "allow-same-origin", "allow-scripts", "allow-top-navigation", "allow-pointer-lock", "allow-popups"
+        "allow-forms", "allow-same-origin", "allow-scripts", "allow-top-navigation", "allow-pointer-lock", "allow-popups", "allow-popups-to-escape-sandbox"
     };
 
     for (auto* supportedPolicy : supportedPolicies) {
@@ -130,6 +130,8 @@
             flags &= ~SandboxPopups;
         else if (equalLettersIgnoringASCIICase(sandboxToken, "allow-pointer-lock"))
             flags &= ~SandboxPointerLock;
+        else if (equalLettersIgnoringASCIICase(sandboxToken, "allow-popups-to-escape-sandbox"))
+            flags &= ~SandboxPropagatesToAuxiliaryBrowsingContexts;
         else {
             if (numberOfTokenErrors)
                 tokenErrors.appendLiteral(", '");

Modified: trunk/Source/WebCore/dom/SecurityContext.h (217999 => 218000)


--- trunk/Source/WebCore/dom/SecurityContext.h	2017-06-09 17:57:06 UTC (rev 217999)
+++ trunk/Source/WebCore/dom/SecurityContext.h	2017-06-09 17:59:18 UTC (rev 218000)
@@ -49,6 +49,7 @@
     SandboxPopups               = 1 << 6, // See https://www.w3.org/Bugs/Public/show_bug.cgi?id=12393
     SandboxAutomaticFeatures    = 1 << 7,
     SandboxPointerLock          = 1 << 8,
+    SandboxPropagatesToAuxiliaryBrowsingContexts = 1 << 9,
     SandboxAll                  = -1 // Mask with all bits set to 1.
 };
 

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (217999 => 218000)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2017-06-09 17:57:06 UTC (rev 217999)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2017-06-09 17:59:18 UTC (rev 218000)
@@ -3160,7 +3160,9 @@
     if (!mainFrame)
         return;
 
-    mainFrame->loader().forceSandboxFlags(frame->loader().effectiveSandboxFlags());
+    SandboxFlags sandboxFlags = frame->loader().effectiveSandboxFlags();
+    if (sandboxFlags & SandboxPropagatesToAuxiliaryBrowsingContexts)
+        mainFrame->loader().forceSandboxFlags(sandboxFlags);
 
     if (!equalIgnoringASCIICase(frameName, "_blank"))
         mainFrame->tree().setName(frameName);
@@ -3704,7 +3706,8 @@
 
     RefPtr<Frame> frame = &page->mainFrame();
 
-    frame->loader().forceSandboxFlags(openerFrame.document()->sandboxFlags());
+    if (isDocumentSandboxed(openerFrame, SandboxPropagatesToAuxiliaryBrowsingContexts))
+        frame->loader().forceSandboxFlags(openerFrame.document()->sandboxFlags());
 
     if (!equalIgnoringASCIICase(request.frameName(), "_blank"))
         frame->tree().setName(request.frameName());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to