Title: [261620] trunk
Revision
261620
Author
[email protected]
Date
2020-05-13 10:03:33 -0700 (Wed, 13 May 2020)

Log Message

Add test for non-app-bound iframe under app-bound domain
https://bugs.webkit.org/show_bug.cgi?id=211815
<rdar://problem/63159707>

Reviewed by Brent Fulgham.

Tools:

Clear the main frame app-bound session before loading the iframe so
we can be sure the iframe uses an app-bound session.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::clearAppBoundSession):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

* http/tests/in-app-browser-privacy/non-app-bound-iframe-under-app-bound-domain-is-app-bound-expected.txt: Added.
* http/tests/in-app-browser-privacy/non-app-bound-iframe-under-app-bound-domain-is-app-bound.html: Added.
* http/tests/in-app-browser-privacy/resources/non-app-bound-iframe.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (261619 => 261620)


--- trunk/LayoutTests/ChangeLog	2020-05-13 16:49:56 UTC (rev 261619)
+++ trunk/LayoutTests/ChangeLog	2020-05-13 17:03:33 UTC (rev 261620)
@@ -1,3 +1,15 @@
+2020-05-13  Kate Cheney  <[email protected]>
+
+        Add test for non-app-bound iframe under app-bound domain
+        https://bugs.webkit.org/show_bug.cgi?id=211815
+        <rdar://problem/63159707>
+
+        Reviewed by Brent Fulgham.
+
+        * http/tests/in-app-browser-privacy/non-app-bound-iframe-under-app-bound-domain-is-app-bound-expected.txt: Added.
+        * http/tests/in-app-browser-privacy/non-app-bound-iframe-under-app-bound-domain-is-app-bound.html: Added.
+        * http/tests/in-app-browser-privacy/resources/non-app-bound-iframe.html: Added.
+
 2020-05-13  Simon Fraser  <[email protected]>
 
         The perspective matrix is affected by overflow:hidden on a box with borders

Added: trunk/LayoutTests/http/tests/in-app-browser-privacy/non-app-bound-iframe-under-app-bound-domain-is-app-bound-expected.txt (0 => 261620)


--- trunk/LayoutTests/http/tests/in-app-browser-privacy/non-app-bound-iframe-under-app-bound-domain-is-app-bound-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/in-app-browser-privacy/non-app-bound-iframe-under-app-bound-domain-is-app-bound-expected.txt	2020-05-13 17:03:33 UTC (rev 261620)
@@ -0,0 +1,11 @@
+Tests that an app-bound domain's iframe also uses an app-bound session.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Origin has app-bound session.
+PASS Frame has app-bound session.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/in-app-browser-privacy/non-app-bound-iframe-under-app-bound-domain-is-app-bound.html (0 => 261620)


--- trunk/LayoutTests/http/tests/in-app-browser-privacy/non-app-bound-iframe-under-app-bound-domain-is-app-bound.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/in-app-browser-privacy/non-app-bound-iframe-under-app-bound-domain-is-app-bound.html	2020-05-13 17:03:33 UTC (rev 261620)
@@ -0,0 +1,47 @@
+<!DOCTYPE html><!-- webkit-test-runner [ enableInAppBrowserPrivacy=true applicationBundleIdentifier=inAppBrowserPrivacyTestIdentifier isAppBoundWebView=true ] -->
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <script src=""
+    <script src=""
+</head>
+<body _onload_="runTest()">
+<script>
+    description("Tests that an app-bound domain's iframe also uses an app-bound session.");
+    jsTestIsAsync = true;
+
+    function receiveMessage(event) {
+        if (event.origin === "http://localhost:8000") {
+            if (event.data.indexOf("PASS") === -1)
+                testFailed(event.data.replace("FAIL ", ""));
+            else
+                testPassed(event.data.replace("PASS ", ""));
+        } else
+            testFailed("Received a message from an unexpected origin: " + event.origin);
+        finishJSTest();
+    }
+
+    window.addEventListener("message", receiveMessage, false);
+
+    function loadFrame() {
+        let iframeElement = document.createElement("iframe");
+        iframeElement.src = ""
+        document.body.appendChild(iframeElement);
+    }
+    
+    function runTest() {
+        if (!testRunner.hasAppBoundSession()) {
+            testFailed("Origin did not start with app-bound session.");
+        } else {
+            testPassed("Origin has app-bound session.");
+            
+            // Clear the app-bound session to make sure the iframe load creates
+            // a new one.
+            testRunner.clearAppBoundSession();
+            loadFrame();
+        }
+    }
+
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/in-app-browser-privacy/resources/non-app-bound-iframe.html (0 => 261620)


--- trunk/LayoutTests/http/tests/in-app-browser-privacy/resources/non-app-bound-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/in-app-browser-privacy/resources/non-app-bound-iframe.html	2020-05-13 17:03:33 UTC (rev 261620)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body _onload_="reportBackLoadedToTopFrame()">
+<script>
+    function reportBackLoadedToTopFrame() {
+        if (testRunner.hasAppBoundSession()) {
+            top.postMessage("PASS Frame has app-bound session.", "http://127.0.0.1:8000");
+        } else {
+            top.postMessage("FAIL Frame does not have app-bound session.", "http://127.0.0.1:8000");
+        }
+    }
+</script>
+</body>
+</html>

Modified: trunk/Tools/ChangeLog (261619 => 261620)


--- trunk/Tools/ChangeLog	2020-05-13 16:49:56 UTC (rev 261619)
+++ trunk/Tools/ChangeLog	2020-05-13 17:03:33 UTC (rev 261620)
@@ -1,3 +1,21 @@
+2020-05-13  Kate Cheney  <[email protected]>
+
+        Add test for non-app-bound iframe under app-bound domain
+        https://bugs.webkit.org/show_bug.cgi?id=211815
+        <rdar://problem/63159707>
+
+        Reviewed by Brent Fulgham.
+
+        Clear the main frame app-bound session before loading the iframe so
+        we can be sure the iframe uses an app-bound session.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::clearAppBoundSession):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+
 2020-05-13  Philippe Normand  <[email protected]>
 
         [Flatpak SDK] Proper handling of sccache scheduler URL command-line argument

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (261619 => 261620)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2020-05-13 16:49:56 UTC (rev 261619)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2020-05-13 17:03:33 UTC (rev 261620)
@@ -395,6 +395,7 @@
     boolean isMockRealtimeMediaSourceCenterEnabled();
 
     boolean hasAppBoundSession();
+    void clearAppBoundSession();
     void setAppBoundDomains(object originsArray, object callback);
 
     void injectUserScript(DOMString string);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (261619 => 261620)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2020-05-13 16:49:56 UTC (rev 261619)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2020-05-13 17:03:33 UTC (rev 261620)
@@ -2976,6 +2976,12 @@
     return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
 }
 
+void TestRunner::clearAppBoundSession()
+{
+    auto messageName = adoptWK(WKStringCreateWithUTF8CString("ClearAppBoundSession"));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);
+}
+
 void TestRunner::setAppBoundDomains(JSValueRef originArray, JSValueRef completionHandler)
 {
     cacheTestRunnerCallback(DidSetAppBoundDomainsCallbackID, completionHandler);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (261619 => 261620)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2020-05-13 16:49:56 UTC (rev 261619)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2020-05-13 17:03:33 UTC (rev 261620)
@@ -502,6 +502,7 @@
     bool isMockRealtimeMediaSourceCenterEnabled();
 
     bool hasAppBoundSession();
+    void clearAppBoundSession();
     void setAppBoundDomains(JSValueRef originArray, JSValueRef callback);
     void didSetAppBoundDomainsCallback();
 

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (261619 => 261620)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2020-05-13 16:49:56 UTC (rev 261619)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2020-05-13 17:03:33 UTC (rev 261620)
@@ -1801,6 +1801,11 @@
         TestController::singleton().clearAdClickAttributionsThroughWebsiteDataRemoval();
         return nullptr;
     }
+    
+    if (WKStringIsEqualToUTF8CString(messageName, "ClearAppBoundSession")) {
+        TestController::singleton().clearAppBoundSession();
+        return nullptr;
+    }
 
     if (WKStringIsEqualToUTF8CString(messageName, "SetAdClickAttributionOverrideTimerForTesting")) {
         ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to