Title: [188988] trunk
Revision
188988
Author
aes...@apple.com
Date
2015-08-26 14:15:49 -0700 (Wed, 26 Aug 2015)

Log Message

Crash when following a Google search link to Twitter with Limit Adult Content enabled
https://bugs.webkit.org/show_bug.cgi?id=147651

Rubber-stamped by Brady Eidson.

Tools:

Taught TestRunner how to decide the navigation policy after a delay.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::decidePolicyForNavigationAction):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setShouldDecideNavigationPolicyAfterDelay):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(WTR::TestRunner::shouldDecideNavigationPolicyAfterDelay):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::initialize):
(WTR::TestController::resetStateToConsistentValues):
(WTR::TestController::decidePolicyForNavigationAction):
* WebKitTestRunner/TestController.h:
(WTR::TestController::setShouldDecideNavigationPolicyAfterDelay):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):

LayoutTests:

Added a layout test.

* http/tests/contentfiltering/load-substitute-data-from-appcache-expected.txt: Added.
* http/tests/contentfiltering/load-substitute-data-from-appcache.html: Added.
* http/tests/contentfiltering/resources/appcache.html: Added.
* http/tests/contentfiltering/resources/appcache.manifest: Added.
* platform/mac-wk1/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (188987 => 188988)


--- trunk/LayoutTests/ChangeLog	2015-08-26 20:44:04 UTC (rev 188987)
+++ trunk/LayoutTests/ChangeLog	2015-08-26 21:15:49 UTC (rev 188988)
@@ -1,3 +1,18 @@
+2015-08-26  Andy Estes  <aes...@apple.com>
+
+        Crash when following a Google search link to Twitter with Limit Adult Content enabled
+        https://bugs.webkit.org/show_bug.cgi?id=147651
+
+        Rubber-stamped by Brady Eidson.
+
+        Added a layout test.
+
+        * http/tests/contentfiltering/load-substitute-data-from-appcache-expected.txt: Added.
+        * http/tests/contentfiltering/load-substitute-data-from-appcache.html: Added.
+        * http/tests/contentfiltering/resources/appcache.html: Added.
+        * http/tests/contentfiltering/resources/appcache.manifest: Added.
+        * platform/mac-wk1/TestExpectations:
+
 2015-08-26  Tim Horton  <timothy_hor...@apple.com>
 
         Layout Test platform/mac/fast/events/content-inset-hit-testing-in-frame.html is flaky

Added: trunk/LayoutTests/http/tests/contentfiltering/load-substitute-data-from-appcache-expected.txt (0 => 188988)


--- trunk/LayoutTests/http/tests/contentfiltering/load-substitute-data-from-appcache-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/contentfiltering/load-substitute-data-from-appcache-expected.txt	2015-08-26 21:15:49 UTC (rev 188988)
@@ -0,0 +1,3 @@
+This is a regression test for webkit.org/b/147651. The test passes if it does not crash.
+
+

Added: trunk/LayoutTests/http/tests/contentfiltering/load-substitute-data-from-appcache.html (0 => 188988)


--- trunk/LayoutTests/http/tests/contentfiltering/load-substitute-data-from-appcache.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/contentfiltering/load-substitute-data-from-appcache.html	2015-08-26 21:15:49 UTC (rev 188988)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<script>
+if (window.internals) {
+    var settings = window.internals.mockContentFilterSettings;
+    settings.enabled = true;
+    settings.decisionPoint = settings.DECISION_POINT_AFTER_ADD_DATA;
+    settings.decision = settings.DECISION_ALLOW;
+}
+
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+    testRunner.setShouldDecideNavigationPolicyAfterDelay(true);
+}
+
+window.addEventListener("message", function() {
+    frames[0].location = "/resources/redirect.php?url=""
+});
+</script>
+<body>
+<p>This is a regression test for <a href="" The test passes if it does not crash.</p>
+<iframe src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/contentfiltering/resources/appcache.html (0 => 188988)


--- trunk/LayoutTests/http/tests/contentfiltering/resources/appcache.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/contentfiltering/resources/appcache.html	2015-08-26 21:15:49 UTC (rev 188988)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html manifest="appcache.manifest">
+<script>
+applicationCache._onnoupdate_ = function() {
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+applicationCache._oncached_ = function() {
+    parent.postMessage("cached", "*");
+}
+</script>
+</html>

Added: trunk/LayoutTests/http/tests/contentfiltering/resources/appcache.manifest (0 => 188988)


--- trunk/LayoutTests/http/tests/contentfiltering/resources/appcache.manifest	                        (rev 0)
+++ trunk/LayoutTests/http/tests/contentfiltering/resources/appcache.manifest	2015-08-26 21:15:49 UTC (rev 188988)
@@ -0,0 +1 @@
+CACHE MANIFEST

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (188987 => 188988)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2015-08-26 20:44:04 UTC (rev 188987)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2015-08-26 21:15:49 UTC (rev 188988)
@@ -141,3 +141,6 @@
 
 ### END OF (2) Failures without bug reports
 ########################################
+
+# This test is WebKit2-only
+http/tests/contentfiltering/load-substitute-data-from-appcache.html

Modified: trunk/Tools/ChangeLog (188987 => 188988)


--- trunk/Tools/ChangeLog	2015-08-26 20:44:04 UTC (rev 188987)
+++ trunk/Tools/ChangeLog	2015-08-26 21:15:49 UTC (rev 188988)
@@ -1,3 +1,28 @@
+2015-08-26  Andy Estes  <aes...@apple.com>
+
+        Crash when following a Google search link to Twitter with Limit Adult Content enabled
+        https://bugs.webkit.org/show_bug.cgi?id=147651
+
+        Rubber-stamped by Brady Eidson.
+
+        Taught TestRunner how to decide the navigation policy after a delay.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::decidePolicyForNavigationAction):
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setShouldDecideNavigationPolicyAfterDelay):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        (WTR::TestRunner::shouldDecideNavigationPolicyAfterDelay):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::initialize):
+        (WTR::TestController::resetStateToConsistentValues):
+        (WTR::TestController::decidePolicyForNavigationAction):
+        * WebKitTestRunner/TestController.h:
+        (WTR::TestController::setShouldDecideNavigationPolicyAfterDelay):
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+
 2015-08-26  Brent Fulgham  <bfulg...@apple.com>
 
         [Win] Rename 'WinLauncher' to 'MiniBrowser'

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (188987 => 188988)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2015-08-26 20:44:04 UTC (rev 188987)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2015-08-26 21:15:49 UTC (rev 188988)
@@ -75,6 +75,7 @@
     void setCacheModel(int model);
     void setAsynchronousSpellCheckingEnabled(boolean value);
     void setPrinting();
+    void setShouldDecideNavigationPolicyAfterDelay(boolean value);
 
     // Special DOM functions.
     void clearBackForwardList();

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (188987 => 188988)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2015-08-26 20:44:04 UTC (rev 188987)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2015-08-26 21:15:49 UTC (rev 188988)
@@ -1286,6 +1286,9 @@
         injectedBundle.outputText(stringBuilder.toString());
     }
 
+    if (injectedBundle.testRunner()->shouldDecideNavigationPolicyAfterDelay())
+        return WKBundlePagePolicyActionPassThrough;
+
     if (!injectedBundle.testRunner()->isPolicyDelegateEnabled())
         return WKBundlePagePolicyActionUse;
 

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (188987 => 188988)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2015-08-26 20:44:04 UTC (rev 188987)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2015-08-26 21:15:49 UTC (rev 188988)
@@ -852,4 +852,12 @@
     return JSC::setNeverInline(context, theFunction);
 }
 
+void TestRunner::setShouldDecideNavigationPolicyAfterDelay(bool value)
+{
+    m_shouldDecideNavigationPolicyAfterDelay = value;
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetShouldDecideNavigationPolicyAfterDelay"));
+    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value));
+    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
+}
+
 } // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (188987 => 188988)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2015-08-26 20:44:04 UTC (rev 188987)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2015-08-26 21:15:49 UTC (rev 188988)
@@ -283,6 +283,9 @@
     JSValueRef numberOfDFGCompiles(JSValueRef theFunction);
     JSValueRef neverInlineFunction(JSValueRef theFunction);
 
+    bool shouldDecideNavigationPolicyAfterDelay() const { return m_shouldDecideNavigationPolicyAfterDelay; }
+    void setShouldDecideNavigationPolicyAfterDelay(bool);
+
 private:
     TestRunner();
 
@@ -333,6 +336,8 @@
     double m_databaseDefaultQuota;
     double m_databaseMaxQuota;
 
+    bool m_shouldDecideNavigationPolicyAfterDelay { false };
+
     bool m_userStyleSheetEnabled;
     WKRetainPtr<WKStringRef> m_userStyleSheetLocation;
 

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (188987 => 188988)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2015-08-26 20:44:04 UTC (rev 188987)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2015-08-26 21:15:49 UTC (rev 188988)
@@ -56,6 +56,7 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <string>
+#include <wtf/RunLoop.h>
 #include <wtf/text/CString.h>
 
 #if PLATFORM(COCOA)
@@ -312,6 +313,8 @@
 
 void TestController::initialize(int argc, const char* argv[])
 {
+    RunLoop::initializeMainRunLoop();
+
     platformInitialize();
 
     Options options;
@@ -724,6 +727,8 @@
     // Reset main page back to about:blank
     m_doneResetting = false;
 
+    m_shouldDecideNavigationPolicyAfterDelay = false;
+
     WKPageLoadURL(m_mainWebView->page(), blankURL());
     runUntil(m_doneResetting, shortTimeout);
     return m_doneResetting;
@@ -1493,12 +1498,19 @@
 
 void TestController::decidePolicyForNavigationAction(WKFramePolicyListenerRef listener)
 {
-    if (m_policyDelegateEnabled && !m_policyDelegatePermissive) {
-        WKFramePolicyListenerIgnore(listener);
-        return;
-    }
+    WKRetainPtr<WKFramePolicyListenerRef> retainedListener { listener };
+    const bool shouldIgnore { m_policyDelegateEnabled && !m_policyDelegatePermissive };
+    std::function<void()> decisionFunction = [shouldIgnore, retainedListener]() {
+        if (shouldIgnore)
+            WKFramePolicyListenerIgnore(retainedListener.get());
+        else
+            WKFramePolicyListenerUse(retainedListener.get());
+    };
 
-    WKFramePolicyListenerUse(listener);
+    if (m_shouldDecideNavigationPolicyAfterDelay)
+        RunLoop::main().dispatch(decisionFunction);
+    else
+        decisionFunction();
 }
 
 void TestController::decidePolicyForNavigationResponse(WKPageRef, WKNavigationResponseRef navigationResponse, WKFramePolicyListenerRef listener, WKTypeRef, const void* clientInfo)

Modified: trunk/Tools/WebKitTestRunner/TestController.h (188987 => 188988)


--- trunk/Tools/WebKitTestRunner/TestController.h	2015-08-26 20:44:04 UTC (rev 188987)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2015-08-26 21:15:49 UTC (rev 188988)
@@ -124,6 +124,8 @@
 
     bool isCurrentInvocation(TestInvocation* invocation) const { return invocation == m_currentInvocation.get(); }
 
+    void setShouldDecideNavigationPolicyAfterDelay(bool value) { m_shouldDecideNavigationPolicyAfterDelay = value; }
+
 private:
     void initialize(int argc, const char* argv[]);
     void createWebViewWithOptions(const ViewOptions&);
@@ -285,6 +287,8 @@
     bool m_shouldLogHistoryClientCallbacks;
     bool m_shouldShowWebView;
 
+    bool m_shouldDecideNavigationPolicyAfterDelay { false };
+
     std::unique_ptr<EventSenderProxy> m_eventSenderProxy;
 
     WorkQueueManager m_workQueueManager;

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (188987 => 188988)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2015-08-26 20:44:04 UTC (rev 188987)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2015-08-26 21:15:49 UTC (rev 188988)
@@ -628,6 +628,13 @@
         return;
     }
 
+    if (WKStringIsEqualToUTF8CString(messageName, "SetShouldDecideNavigationPolicyAfterDelay")) {
+        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
+        WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);
+        TestController::singleton().setShouldDecideNavigationPolicyAfterDelay(WKBooleanGetValue(value));
+        return;
+    }
+
     ASSERT_NOT_REACHED();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to