WebKit Bugzilla
Attachment 341812 Details for
Bug 186214
: Have WebKitTestRunner check for abandoned documents
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Hacky patch
check-for-abandoned-documents.patch (text/plain), 10.45 KB, created by
Simon Fraser (smfr)
on 2018-06-01 17:54:16 PDT
(
hide
)
Description:
Hacky patch
Filename:
MIME Type:
Creator:
Simon Fraser (smfr)
Created:
2018-06-01 17:54:16 PDT
Size:
10.45 KB
patch
obsolete
>diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp b/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp >index 7b51504ae57..53785df020d 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp >+++ b/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp >@@ -213,6 +213,11 @@ void WKBundleSetAsynchronousSpellCheckingEnabled(WKBundleRef bundleRef, WKBundle > toImpl(bundleRef)->setAsynchronousSpellCheckingEnabled(toImpl(pageGroupRef), enabled); > } > >+WKArrayRef WKBundleGetLiveDocumentURLs(WKBundleRef bundleRef) >+{ >+ return toAPI(&API::Array::createStringArray(toImpl(bundleRef)->liveDocumentURLs()).leakRef()); >+} >+ > void WKBundleReportException(JSContextRef context, JSValueRef exception) > { > InjectedBundle::reportException(context, exception); >diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h b/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h >index e42422890c0..20ba6316d8d 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h >+++ b/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h >@@ -68,6 +68,7 @@ WK_EXPORT void WKBundleRemoveAllWebNotificationPermissions(WKBundleRef bundle, W > WK_EXPORT uint64_t WKBundleGetWebNotificationID(WKBundleRef bundle, JSContextRef context, JSValueRef notification); > WK_EXPORT WKDataRef WKBundleCreateWKDataFromUInt8Array(WKBundleRef bundle, JSContextRef context, JSValueRef data); > WK_EXPORT void WKBundleSetAsynchronousSpellCheckingEnabled(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled); >+WK_EXPORT WKArrayRef WKBundleGetLiveDocumentURLs(WKBundleRef bundle); > > // UserContent API > WK_EXPORT void WKBundleAddUserScript(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKBundleScriptWorldRef scriptWorld, WKStringRef source, WKURLRef url, WKArrayRef whitelist, WKArrayRef blacklist, _WKUserScriptInjectionTime injectionTime, WKUserContentInjectedFrames injectedFrames); >diff --git a/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp b/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp >index 0f3b9b7386d..f842b8426f9 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp >+++ b/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp >@@ -55,6 +55,7 @@ > #include <WebCore/ApplicationCache.h> > #include <WebCore/ApplicationCacheStorage.h> > #include <WebCore/CommonVM.h> >+#include <WebCore/Document.h> > #include <WebCore/Frame.h> > #include <WebCore/FrameLoader.h> > #include <WebCore/FrameView.h> >@@ -605,6 +606,16 @@ Ref<API::Data> InjectedBundle::createWebDataFromUint8Array(JSContextRef context, > return API::Data::create(static_cast<unsigned char*>(arrayData->baseAddress()), arrayData->byteLength()); > } > >+Vector<String> InjectedBundle::liveDocumentURLs() >+{ >+ Vector<String> result; >+ >+ for (const auto* document : Document::allDocuments()) >+ result.append(document->url().string()); >+ >+ return result; >+} >+ > void InjectedBundle::setTabKeyCyclesThroughElements(WebPage* page, bool enabled) > { > page->corePage()->setTabKeyCyclesThroughElements(enabled); >diff --git a/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.h b/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.h >index 6f8fe7bd892..0a0640498fe 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.h >+++ b/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.h >@@ -121,6 +121,7 @@ public: > void removeAllWebNotificationPermissions(WebPage*); > uint64_t webNotificationID(JSContextRef, JSValueRef); > Ref<API::Data> createWebDataFromUint8Array(JSContextRef, JSValueRef); >+ Vector<String> liveDocumentURLs(); > > // UserContent API > void addUserScript(WebPageGroupProxy*, InjectedBundleScriptWorld*, String&& source, String&& url, API::Array* whitelist, API::Array* blacklist, WebCore::UserScriptInjectionTime, WebCore::UserContentInjectedFrames); >diff --git a/Tools/Scripts/webkitpy/port/driver.py b/Tools/Scripts/webkitpy/port/driver.py >index f1295caa927..79ec23d691f 100644 >--- a/Tools/Scripts/webkitpy/port/driver.py >+++ b/Tools/Scripts/webkitpy/port/driver.py >@@ -489,6 +489,11 @@ class Driver(object): > self.error_from_test += error_line > self._server_process.write('#SAMPLE FINISHED\n', True) # Must be able to ignore a broken pipe here, target process may already be closed. > return True >+ elif error_line.startswith("#ABANDONED DOCUMENT - "): >+ err_line = 'Detected abandoned document: ' + error_line >+ print '\n' + error_line >+ self.error_from_test += err_line >+ return False > return self.has_crashed() > > def _command_from_driver_input(self, driver_input): >diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp >index da162cbd05e..e5dbbc0beae 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp >@@ -253,6 +253,22 @@ void InjectedBundle::didReceiveMessageToPage(WKBundlePageRef page, WKStringRef m > return; > } > >+ if (WKStringIsEqualToUTF8CString(messageName, "CheckForLiveDocuments")) { >+ >+ WKBundleGarbageCollectJavaScriptObjects(m_bundle); >+ WKBundleGarbageCollectJavaScriptObjects(m_bundle); >+ WKBundleGarbageCollectJavaScriptObjects(m_bundle); >+ >+ // FIXME: clear the page cache if necessary. >+ >+ WKRetainPtr<WKArrayRef> documentURLs(AdoptWK, WKBundleGetLiveDocumentURLs(m_bundle)); >+ >+ WKRetainPtr<WKStringRef> ackMessageName(AdoptWK, WKStringCreateWithUTF8CString("LiveDocuments")); >+ WKBundlePagePostMessage(page, ackMessageName.get(), documentURLs.get()); >+ >+ return; >+ } >+ > if (WKStringIsEqualToUTF8CString(messageName, "CallAddChromeInputFieldCallback")) { > m_testRunner->callAddChromeInputFieldCallback(); > return; >diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp >index 2ac9ec60a75..6ebd298bb91 100644 >--- a/Tools/WebKitTestRunner/TestController.cpp >+++ b/Tools/WebKitTestRunner/TestController.cpp >@@ -898,9 +898,21 @@ bool TestController::resetStateToConsistentValues(const TestOptions& options) > m_doneResetting = false; > WKPageLoadURL(m_mainWebView->page(), blankURL()); > runUntil(m_doneResetting, m_currentInvocation->shortTimeout()); >+ if (!m_doneResetting) >+ return false; >+ >+ m_doneResetting = false; >+ checkForLiveDocuments(); >+ runUntil(m_doneResetting, m_currentInvocation->shortTimeout()); > return m_doneResetting; > } > >+void TestController::checkForLiveDocuments() >+{ >+ WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CheckForLiveDocuments")); >+ WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0); >+} >+ > void TestController::terminateWebContentProcess() > { > WKPageTerminate(m_mainWebView->page()); >@@ -1361,6 +1373,39 @@ void TestController::didReceiveKeyDownMessageFromInjectedBundle(WKDictionaryRef > > void TestController::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody) > { >+ if (WKStringIsEqualToUTF8CString(messageName, "LiveDocuments")) { >+ ASSERT(WKGetTypeID(messageBody) == WKArrayGetTypeID()); >+ WKArrayRef liveDocumentURLsArray = static_cast<WKArrayRef>(messageBody); >+ >+ auto numDocuments = WKArrayGetSize(liveDocumentURLsArray); >+ if (!numDocuments) { >+ m_doneResetting = true; >+ return; >+ } >+ >+ Vector<String> documentURLs; >+ for (size_t i = 0, size = WKArrayGetSize(liveDocumentURLsArray); i < size; ++i) { >+ WKTypeRef item = WKArrayGetItemAtIndex(liveDocumentURLsArray, i); >+ if (item && WKGetTypeID(item) == WKStringGetTypeID()) >+ documentURLs.append(toWTFString(static_cast<WKStringRef>(item))); >+ } >+ >+ // We expect one "about:blank". >+ documentURLs.removeFirst("about:blank"); >+ if (!documentURLs.size()) { >+ m_doneResetting = true; >+ return; >+ >+ } >+ >+ fprintf(stderr, "#ABANDONED DOCUMENT COUNT - %lu\n", documentURLs.size()); >+ for (const auto& url : documentURLs) >+ fprintf(stderr, "#ABANDONED DOCUMENT - %s\n", url.utf8().data()); >+ >+ m_doneResetting = true; >+ return; >+ } >+ > if (WKStringIsEqualToUTF8CString(messageName, "EventSender")) { > if (m_state != RunningTest) > return; >diff --git a/Tools/WebKitTestRunner/TestController.h b/Tools/WebKitTestRunner/TestController.h >index bc10f6cbd0c..08be5fcd8f7 100644 >--- a/Tools/WebKitTestRunner/TestController.h >+++ b/Tools/WebKitTestRunner/TestController.h >@@ -23,8 +23,7 @@ > * THE POSSIBILITY OF SUCH DAMAGE. > */ > >-#ifndef TestController_h >-#define TestController_h >+#pragma once > > #include "GeolocationProviderMock.h" > #include "WebNotificationProvider.h" >@@ -127,6 +126,8 @@ public: > void terminateWebContentProcess(); > void reattachPageToWebProcess(); > >+ void checkForLiveDocuments(); >+ > static const char* webProcessName(); > static const char* networkProcessName(); > static const char* databaseProcessName(); >@@ -447,4 +448,3 @@ struct TestCommand { > > } // namespace WTR > >-#endif // TestController_h >diff --git a/Tools/DumpRenderTree/mac/DumpRenderTree.mm b/Tools/DumpRenderTree/mac/DumpRenderTree.mm >index 801656f5e360f12db4b0e7752e11ad590e8ac5f8..c92222cd540230a2ce9b0feda23591f696392112 100644 >--- a/Tools/DumpRenderTree/mac/DumpRenderTree.mm >+++ b/Tools/DumpRenderTree/mac/DumpRenderTree.mm >@@ -60,6 +60,7 @@ > #import <JavaScriptCore/TestRunnerUtils.h> > #import <WebCore/LogInitialization.h> > #import <WebCore/NetworkStorageSession.h> >+#import <WebCore/Document.h> // EVIL > #import <WebKit/DOMElement.h> > #import <WebKit/DOMExtensions.h> > #import <WebKit/DOMRange.h> >@@ -2075,7 +2076,16 @@ static void runTest(const string& inputLine) > > if (gcBetweenTests) > [WebCoreStatistics garbageCollectJavaScriptObjects]; >- >+ >+ [WebCoreStatistics garbageCollectJavaScriptObjects]; >+ [WebCoreStatistics garbageCollectJavaScriptObjects]; >+ [WebCoreStatistics garbageCollectJavaScriptObjects]; >+ >+ WTFLogAlways("%u live documents:", WebCore::Document::allDocuments().size()); >+ for (const auto* document : WebCore::Document::allDocuments()) { >+ WTFLogAlways("Document %p (refCount %d) %s", document, document->refCount(), document->url().string().utf8().data()); >+ } >+ > JSC::waitForVMDestruction(); > > fputs("#EOF\n", stderr);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186214
:
341812
|
347422
|
347424
|
347425
|
347429
|
347431
|
347433
|
347445