WebKitTestRunner can leak user content script results between tests
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Sep 2015 00:28:42 +0000 (00:28 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Sep 2015 00:28:42 +0000 (00:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149391

Reviewed by Sam Weinig.

Move WKBundlePageRemoveAllUserContent call so that it's executed before loading
about:blank, and thus about:blank doesn't have unintended side effects.

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::beginTesting):
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::resetAfterTest):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190035 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp

index e991011..61a6e16 100644 (file)
@@ -1,5 +1,20 @@
 2015-09-20  Alexey Proskuryakov  <ap@apple.com>
 
+        WebKitTestRunner can leak user content script results between tests
+        https://bugs.webkit.org/show_bug.cgi?id=149391
+
+        Reviewed by Sam Weinig.
+
+        Move WKBundlePageRemoveAllUserContent call so that it's executed before loading
+        about:blank, and thus about:blank doesn't have unintended side effects.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::beginTesting):
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::resetAfterTest):
+
+2015-09-20  Alexey Proskuryakov  <ap@apple.com>
+
         [Mac, iOS] AccessibilityController doesn't uninstall global notification handler
         https://bugs.webkit.org/show_bug.cgi?id=149384
 
index 6665a2a..6f89a65 100644 (file)
@@ -281,8 +281,6 @@ void InjectedBundle::beginTesting(WKDictionaryRef settings)
     WKBundleSetPluginsEnabled(m_bundle, m_pageGroup, true);
     WKBundleSetPopupBlockingEnabled(m_bundle, m_pageGroup, false);
 
-    WKBundlePageRemoveAllUserContent(page()->page());
-
 #if PLATFORM(IOS)
     WKBundlePageSetUseTestingViewportConfiguration(page()->page(), !booleanForKey(settings, "UseFlexibleViewport"));
 #endif
index cb22d6d..7cb2132 100644 (file)
@@ -427,6 +427,9 @@ void InjectedBundlePage::resetAfterTest()
     JSGlobalContextRef context = WKBundleFrameGetJavaScriptContext(frame);
     WebCoreTestSupport::resetInternalsObject(context);
     assignedUrlsCache.clear();
+
+    // User scripts need to be removed after the test and before loading about:blank, as otherwise they would run in about:blank, and potentially leak results into a subsequest test.
+    WKBundlePageRemoveAllUserContent(m_page);
 }
 
 // Loader Client Callbacks