From 0ee3e323ac9242930b5a53a8d200a11947338de7 Mon Sep 17 00:00:00 2001 From: Rob Buis Date: Thu, 11 Feb 2021 06:22:38 +0000 Subject: [PATCH] Use event loop to set title https://bugs.webkit.org/show_bug.cgi?id=218496 Patch by Rob Buis on 2021-02-10 Reviewed by Darin Adler. Source/WebCore: Use event loop to set title to avoid calling WebFrameLoaderClient within HTMLTitleElement::insertedIntoAncestor. * dom/Document.cpp: (WebCore::Document::updateTitle): * dom/Document.h: (WebCore::Document::titleWithDirection const): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::setTitle): * loader/EmptyClients.h: * page/Chrome.cpp: (WebCore::Chrome::print): * page/ChromeClient.h: Source/WebKit: Add title parameter to PrintFrame message. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::printFrame): * UIProcess/WebPageProxy.h: * UIProcess/WebPageProxy.messages.in: * WebProcess/WebCoreSupport/WebChromeClient.cpp: (WebKit::WebChromeClient::print): * WebProcess/WebCoreSupport/WebChromeClient.h: Source/WebKitLegacy/mac: Adjust to API change. * WebCoreSupport/WebChromeClient.h: * WebCoreSupport/WebChromeClient.mm: (WebChromeClient::print): Source/WebKitLegacy/win: Adjust to API change. * WebCoreSupport/WebChromeClient.cpp: (WebChromeClient::print): * WebCoreSupport/WebChromeClient.h: Tools: Adapt unit tests to wait for title change tasks to be processed. * TestWebKitAPI/Tests/WebKit/PageLoadState.cpp: (TestWebKitAPI::didChangeTitle): (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm: (TEST): * TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp: (testWebViewAuthenticationFailure): (testWebViewAuthenticationNoCredential): (testWebViewAuthenticationSuccess): (testWebViewAuthenticationEmptyRealm): * TestWebKitAPI/Tests/WebKitGLib/TestBackForwardList.cpp: (testBackForwardListNavigation): * TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp: (testWebViewTitle): * TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp: (testLoadFailedWithTLSErrors): * TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp: (testWebKitSettingsJavaScriptMarkup): * TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp: (testWebViewTitleChange): LayoutTests: Adapt tests to make sure pending title change tasks are processed before the test is done. * TestExpectations: * fast/dom/title-text-property-2.html: * fast/dom/title-text-property-assigning-empty-string.html: * fast/dom/title-text-property.html: * http/tests/globalhistory/history-delegate-basic-title-expected.txt: * http/tests/globalhistory/history-delegate-basic-title.html: * http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt: * http/tests/loading/basic-auth-load-URL-with-consecutive-slashes.html: * http/tests/loading/redirect-with-no-location-crash-expected.txt: * http/tests/loading/redirect-with-no-location-crash.html: * platform/mac-wk2/TestExpectations: * platform/win/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt: Copied from LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt. * platform/wk2/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt: * platform/wk2/http/tests/loading/redirect-with-no-location-crash-expected.txt: Canonical link: https://commits.webkit.org/233952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272707 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 25 +++++++++++++++ LayoutTests/TestExpectations | 3 -- .../fast/dom/title-text-property-2.html | 15 +++++++-- ...-text-property-assigning-empty-string.html | 10 ++++-- LayoutTests/fast/dom/title-text-property.html | 3 ++ .../history-delegate-basic-title-expected.txt | 1 - .../history-delegate-basic-title.html | 11 +++++-- ...-URL-with-consecutive-slashes-expected.txt | 5 +-- ...uth-load-URL-with-consecutive-slashes.html | 12 ++++--- ...direct-with-no-location-crash-expected.txt | 1 - .../redirect-with-no-location-crash.html | 6 ++-- LayoutTests/platform/mac-wk2/TestExpectations | 2 -- ...-URL-with-consecutive-slashes-expected.txt | 20 ++++++++++++ ...-URL-with-consecutive-slashes-expected.txt | 7 +++-- ...direct-with-no-location-crash-expected.txt | 1 - Source/WebCore/ChangeLog | 21 +++++++++++++ Source/WebCore/dom/Document.cpp | 10 ++++-- Source/WebCore/dom/Document.h | 3 ++ Source/WebCore/loader/DocumentLoader.cpp | 3 +- Source/WebCore/loader/EmptyClients.h | 2 +- Source/WebCore/page/Chrome.cpp | 2 +- Source/WebCore/page/ChromeClient.h | 2 +- Source/WebKit/ChangeLog | 17 ++++++++++ Source/WebKit/UIProcess/WebPageProxy.cpp | 4 ++- Source/WebKit/UIProcess/WebPageProxy.h | 2 +- .../WebKit/UIProcess/WebPageProxy.messages.in | 2 +- .../WebCoreSupport/WebChromeClient.cpp | 7 +++-- .../WebCoreSupport/WebChromeClient.h | 2 +- Source/WebKitLegacy/mac/ChangeLog | 13 ++++++++ .../mac/WebCoreSupport/WebChromeClient.h | 2 +- .../mac/WebCoreSupport/WebChromeClient.mm | 2 +- Source/WebKitLegacy/win/ChangeLog | 13 ++++++++ .../win/WebCoreSupport/WebChromeClient.cpp | 2 +- .../win/WebCoreSupport/WebChromeClient.h | 2 +- Tools/ChangeLog | 31 +++++++++++++++++++ .../Tests/WebKit/PageLoadState.cpp | 10 +++--- .../Tests/WebKitCocoa/UIDelegate.mm | 2 +- .../Tests/WebKitGLib/TestAuthentication.cpp | 9 +++--- .../Tests/WebKitGLib/TestBackForwardList.cpp | 2 ++ .../Tests/WebKitGLib/TestLoaderClient.cpp | 2 +- .../Tests/WebKitGLib/TestSSL.cpp | 2 +- .../Tests/WebKitGLib/TestWebKitSettings.cpp | 2 +- .../Tests/WebKitGLib/TestWebKitWebView.cpp | 16 +++++----- 43 files changed, 246 insertions(+), 63 deletions(-) create mode 100644 LayoutTests/platform/win/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 13ec6d43c438..f678dceb4e85 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,28 @@ +2021-02-10 Rob Buis + + Use event loop to set title + https://bugs.webkit.org/show_bug.cgi?id=218496 + + Reviewed by Darin Adler. + + Adapt tests to make sure pending title change tasks + are processed before the test is done. + + * TestExpectations: + * fast/dom/title-text-property-2.html: + * fast/dom/title-text-property-assigning-empty-string.html: + * fast/dom/title-text-property.html: + * http/tests/globalhistory/history-delegate-basic-title-expected.txt: + * http/tests/globalhistory/history-delegate-basic-title.html: + * http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt: + * http/tests/loading/basic-auth-load-URL-with-consecutive-slashes.html: + * http/tests/loading/redirect-with-no-location-crash-expected.txt: + * http/tests/loading/redirect-with-no-location-crash.html: + * platform/mac-wk2/TestExpectations: + * platform/win/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt: Copied from LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt. + * platform/wk2/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt: + * platform/wk2/http/tests/loading/redirect-with-no-location-crash-expected.txt: + 2021-02-10 Ryan Haddad [ Big Sur ] imported/w3c/web-platform-tests/css/css-flexbox/contain-size-layout-abspos-flex-container-crash.html is failing diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations index e8d17b07752d..52b152e0a450 100644 --- a/LayoutTests/TestExpectations +++ b/LayoutTests/TestExpectations @@ -4743,6 +4743,3 @@ webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-004 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-014.html [ ImageOnlyFailure ] # Requires fallback (at parse time) support webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-015.html [ ImageOnlyFailure ] # Requires fallback (at parse time) support (unclear if this makes sense) webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-017.html [ ImageOnlyFailure ] # Invalid test, percentages are not allowed for color(xyz). - -webkit.org/b/218496 http/tests/loading/redirect-with-no-location-crash.html [ Skip ] - diff --git a/LayoutTests/fast/dom/title-text-property-2.html b/LayoutTests/fast/dom/title-text-property-2.html index f8809675dc69..41f9218bcc7c 100644 --- a/LayoutTests/fast/dom/title-text-property-2.html +++ b/LayoutTests/fast/dom/title-text-property-2.html @@ -1,8 +1,9 @@ Initial title - + diff --git a/LayoutTests/fast/dom/title-text-property-assigning-empty-string.html b/LayoutTests/fast/dom/title-text-property-assigning-empty-string.html index 93a85d2b9a21..0e76a8ab4821 100644 --- a/LayoutTests/fast/dom/title-text-property-assigning-empty-string.html +++ b/LayoutTests/fast/dom/title-text-property-assigning-empty-string.html @@ -1,17 +1,23 @@ - + diff --git a/LayoutTests/fast/dom/title-text-property.html b/LayoutTests/fast/dom/title-text-property.html index 2a87e72ac428..581aec46414c 100644 --- a/LayoutTests/fast/dom/title-text-property.html +++ b/LayoutTests/fast/dom/title-text-property.html @@ -12,6 +12,7 @@ function runTests() { if (window.testRunner) { + testRunner.waitUntilDone(); testRunner.dumpAsText(); testRunner.dumpTitleChanges(); } @@ -24,6 +25,8 @@ titleElem.text = newTitle; debugOutput('New title is: \'' + titleElem.text + '\''); + + internals.queueTask("DOMManipulation", () => testRunner.notifyDone()); } diff --git a/LayoutTests/http/tests/globalhistory/history-delegate-basic-title-expected.txt b/LayoutTests/http/tests/globalhistory/history-delegate-basic-title-expected.txt index ed25a80cfc8e..dd1341603c66 100644 --- a/LayoutTests/http/tests/globalhistory/history-delegate-basic-title-expected.txt +++ b/LayoutTests/http/tests/globalhistory/history-delegate-basic-title-expected.txt @@ -1,4 +1,3 @@ WebView navigated to url "http://127.0.0.1:8000/globalhistory/history-delegate-basic-title.html" with title "" with HTTP equivalent method "GET". The navigation was successful and was not a client redirect. -WebView updated the title for history URL "http://127.0.0.1:8000/globalhistory/history-delegate-basic-title.html" to "Test Title 1". WebView updated the title for history URL "http://127.0.0.1:8000/globalhistory/history-delegate-basic-title.html" to "Test Title 2". This test sees if the history delegate is notified of title changes. diff --git a/LayoutTests/http/tests/globalhistory/history-delegate-basic-title.html b/LayoutTests/http/tests/globalhistory/history-delegate-basic-title.html index d30ca76d7380..2ba7d4a8557b 100644 --- a/LayoutTests/http/tests/globalhistory/history-delegate-basic-title.html +++ b/LayoutTests/http/tests/globalhistory/history-delegate-basic-title.html @@ -1,15 +1,20 @@ Test Title 1 - + This test sees if the history delegate is notified of title changes. - + diff --git a/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt b/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt index 60ef13b0a8f0..b1f246fb062b 100644 --- a/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt +++ b/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt @@ -5,8 +5,8 @@ main frame - didFinishDocumentLoadForFrame http://127.0.0.1:8000/loading/resources/basic-auth-testing.php?username=webkit&password=rocks - didReceiveAuthenticationChallenge - Responding with webkit:rocks frame "" - didCommitLoadForFrame frame "" - didFinishDocumentLoadForFrame -frame "" - willPerformClientRedirectToURL: http://127.0.0.1:8000/a//b/non-existent-file.html frame "" - didHandleOnloadEventsForFrame +frame "" - willPerformClientRedirectToURL: http://127.0.0.1:8000/a//b/non-existent-file.html main frame - didHandleOnloadEventsForFrame frame "" - didFinishLoadForFrame main frame - didFinishLoadForFrame @@ -15,5 +15,6 @@ frame "" - didCancelClientRedirectForFrame frame "" - didCommitLoadForFrame frame "" - didReceiveTitle: 404 Not Found frame "" - didFinishDocumentLoadForFrame -frame "" - didFailLoadWithError +frame "" - didHandleOnloadEventsForFrame +frame "" - didFinishLoadForFrame PASS did not cause assertion failure. diff --git a/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes.html b/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes.html index 209e6652ba7c..6cdd09a9603b 100644 --- a/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes.html +++ b/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes.html @@ -12,9 +12,11 @@ function done() { - document.body.removeChild(document.getElementById("frame")); - if (window.testRunner) - testRunner.notifyDone(); + setTimeout(function() { + document.body.removeChild(document.getElementById("frame")); + if (window.testRunner) + testRunner.notifyDone(); + }, 500); } function notifyFrameDidLoad(frame) @@ -24,8 +26,8 @@ } - - + +

PASS did not cause assertion failure.

diff --git a/LayoutTests/http/tests/loading/redirect-with-no-location-crash-expected.txt b/LayoutTests/http/tests/loading/redirect-with-no-location-crash-expected.txt index 88f20964786f..3c8ae9a7526b 100644 --- a/LayoutTests/http/tests/loading/redirect-with-no-location-crash-expected.txt +++ b/LayoutTests/http/tests/loading/redirect-with-no-location-crash-expected.txt @@ -1,6 +1,5 @@ main frame - didStartProvisionalLoadForFrame main frame - didCommitLoadForFrame -main frame - didReceiveTitle: Test for https://bugs.webkit.org/show_bug.cgi?id=29293 frame "" - didStartProvisionalLoadForFrame main frame - didFinishDocumentLoadForFrame frame "" - didCommitLoadForFrame diff --git a/LayoutTests/http/tests/loading/redirect-with-no-location-crash.html b/LayoutTests/http/tests/loading/redirect-with-no-location-crash.html index 643e5fd34d1e..b4ba472902e8 100644 --- a/LayoutTests/http/tests/loading/redirect-with-no-location-crash.html +++ b/LayoutTests/http/tests/loading/redirect-with-no-location-crash.html @@ -2,11 +2,13 @@ - + diff --git a/LayoutTests/platform/mac-wk2/TestExpectations b/LayoutTests/platform/mac-wk2/TestExpectations index 9c67678bcb75..55f43b3a1c35 100644 --- a/LayoutTests/platform/mac-wk2/TestExpectations +++ b/LayoutTests/platform/mac-wk2/TestExpectations @@ -583,8 +583,6 @@ webkit.org/b/161649 [ Debug ] http/tests/cache/disk-cache/resource-becomes-uncac webkit.org/b/163136 http/tests/xmlhttprequest/auth-reject-protection-space.html [ Pass Failure ] -webkit.org/b/163139 http/tests/loading/basic-auth-load-URL-with-consecutive-slashes.html [ Pass Failure ] - webkit.org/b/162975 http/tests/cache/disk-cache/memory-cache-revalidation-updates-disk-cache.html [ Pass Failure ] webkit.org/b/161653 [ Debug ] storage/indexeddb/key-generator.html [ Pass Timeout ] diff --git a/LayoutTests/platform/win/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt b/LayoutTests/platform/win/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt new file mode 100644 index 000000000000..2cc9d1017a26 --- /dev/null +++ b/LayoutTests/platform/win/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt @@ -0,0 +1,20 @@ +main frame - didStartProvisionalLoadForFrame +main frame - didCommitLoadForFrame +frame "" - didStartProvisionalLoadForFrame +main frame - didFinishDocumentLoadForFrame +http://127.0.0.1:8000/loading/resources/basic-auth-testing.php?username=webkit&password=rocks - didReceiveAuthenticationChallenge - Responding with webkit:rocks +frame "" - didCommitLoadForFrame +frame "" - didFinishDocumentLoadForFrame +frame "" - didHandleOnloadEventsForFrame +frame "" - willPerformClientRedirectToURL: http://127.0.0.1:8000/a//b/non-existent-file.html +main frame - didHandleOnloadEventsForFrame +frame "" - didFinishLoadForFrame +main frame - didFinishLoadForFrame +frame "" - didStartProvisionalLoadForFrame +frame "" - didCancelClientRedirectForFrame +frame "" - didCommitLoadForFrame +frame "" - didFinishDocumentLoadForFrame +frame "" - didHandleOnloadEventsForFrame +frame "" - didFinishLoadForFrame +frame "" - didReceiveTitle: 404 Not Found +PASS did not cause assertion failure. diff --git a/LayoutTests/platform/wk2/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt b/LayoutTests/platform/wk2/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt index 2038050b2362..c722af067e9f 100644 --- a/LayoutTests/platform/wk2/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt +++ b/LayoutTests/platform/wk2/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt @@ -5,15 +5,16 @@ frame "" - didStartProvisionalLoadForFrame 127.0.0.1:8000 - didReceiveAuthenticationChallenge - ProtectionSpaceAuthenticationSchemeHTTPBasic - Responding with webkit:rocks frame "" - didCommitLoadForFrame frame "" - didFinishDocumentLoadForFrame -frame "" - willPerformClientRedirectToURL: http://127.0.0.1:8000/a//b/non-existent-file.html frame "" - didHandleOnloadEventsForFrame +frame "" - willPerformClientRedirectToURL: http://127.0.0.1:8000/a//b/non-existent-file.html main frame - didHandleOnloadEventsForFrame frame "" - didFinishLoadForFrame main frame - didFinishLoadForFrame frame "" - didStartProvisionalLoadForFrame frame "" - didCancelClientRedirectForFrame frame "" - didCommitLoadForFrame -frame "" - didReceiveTitle: 404 Not Found frame "" - didFinishDocumentLoadForFrame -frame "" - didFailLoadWithError +frame "" - didHandleOnloadEventsForFrame +frame "" - didFinishLoadForFrame +frame "" - didReceiveTitle: 404 Not Found PASS did not cause assertion failure. diff --git a/LayoutTests/platform/wk2/http/tests/loading/redirect-with-no-location-crash-expected.txt b/LayoutTests/platform/wk2/http/tests/loading/redirect-with-no-location-crash-expected.txt index 02aadfe3d221..70247cc09f63 100644 --- a/LayoutTests/platform/wk2/http/tests/loading/redirect-with-no-location-crash-expected.txt +++ b/LayoutTests/platform/wk2/http/tests/loading/redirect-with-no-location-crash-expected.txt @@ -1,6 +1,5 @@ main frame - didStartProvisionalLoadForFrame main frame - didCommitLoadForFrame -main frame - didReceiveTitle: Test for https://bugs.webkit.org/show_bug.cgi?id=29293 main frame - didFinishDocumentLoadForFrame frame "" - didStartProvisionalLoadForFrame frame "" - didCommitLoadForFrame diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 334a36f2aaf4..2a16de0d1234 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,24 @@ +2021-02-10 Rob Buis + + Use event loop to set title + https://bugs.webkit.org/show_bug.cgi?id=218496 + + Reviewed by Darin Adler. + + Use event loop to set title to avoid calling WebFrameLoaderClient + within HTMLTitleElement::insertedIntoAncestor. + + * dom/Document.cpp: + (WebCore::Document::updateTitle): + * dom/Document.h: + (WebCore::Document::titleWithDirection const): + * loader/DocumentLoader.cpp: + (WebCore::DocumentLoader::setTitle): + * loader/EmptyClients.h: + * page/Chrome.cpp: + (WebCore::Chrome::print): + * page/ChromeClient.h: + 2021-02-10 Myles C. Maxfield Move pal/spi/cocoa/CoreTextSPI.h to pal/spi/cf/CoreTextSPI.h diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp index 5ca0e49ac6ff..44f9d0ea5052 100644 --- a/Source/WebCore/dom/Document.cpp +++ b/Source/WebCore/dom/Document.cpp @@ -1687,8 +1687,14 @@ void Document::updateTitle(const StringWithDirection& title) m_title.string = canonicalizedTitle(*this, title.string); m_title.direction = title.direction; - if (auto* loader = this->loader()) - loader->setTitle(m_title); + if (!m_updateTitleTaskScheduled) { + eventLoop().queueTask(TaskSource::DOMManipulation, [protectedThis = makeRef(*this), this]() mutable { + m_updateTitleTaskScheduled = false; + if (auto documentLoader = makeRefPtr(loader())) + documentLoader->setTitle(m_title); + }); + m_updateTitleTaskScheduled = true; + } } void Document::updateTitleFromTitleElement() diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h index f15b06495a30..3acdfd73a719 100644 --- a/Source/WebCore/dom/Document.h +++ b/Source/WebCore/dom/Document.h @@ -924,6 +924,7 @@ class Document // Used by DOM bindings; no direction known. const String& title() const { return m_title.string; } WEBCORE_EXPORT void setTitle(const String&); + const StringWithDirection& titleWithDirection() const { return m_title; } WEBCORE_EXPORT const AtomString& dir() const; WEBCORE_EXPORT void setDir(const AtomString&); @@ -2122,6 +2123,8 @@ class Document bool m_didDispatchViewportPropertiesChanged { false }; #endif + bool m_updateTitleTaskScheduled { false }; + OrientationNotifier m_orientationNotifier; mutable RefPtr m_logger; RefPtr m_consoleMessageListener; diff --git a/Source/WebCore/loader/DocumentLoader.cpp b/Source/WebCore/loader/DocumentLoader.cpp index 7279dda136c5..ad53f719864c 100644 --- a/Source/WebCore/loader/DocumentLoader.cpp +++ b/Source/WebCore/loader/DocumentLoader.cpp @@ -1721,7 +1721,8 @@ void DocumentLoader::setTitle(const StringWithDirection& title) frameLoader()->willChangeTitle(this); m_pageTitle = title; - frameLoader()->didChangeTitle(this); + if (frameLoader()) + frameLoader()->didChangeTitle(this); } URL DocumentLoader::urlForHistory() const diff --git a/Source/WebCore/loader/EmptyClients.h b/Source/WebCore/loader/EmptyClients.h index 9f1bea446e15..a788b45aad15 100644 --- a/Source/WebCore/loader/EmptyClients.h +++ b/Source/WebCore/loader/EmptyClients.h @@ -125,7 +125,7 @@ class EmptyChromeClient : public ChromeClient { void mouseDidMoveOverElement(const HitTestResult&, unsigned, const String&, TextDirection) final { } - void print(Frame&) final { } + void print(Frame&, const StringWithDirection&) final { } void exceededDatabaseQuota(Frame&, const String&, DatabaseDetails) final { } diff --git a/Source/WebCore/page/Chrome.cpp b/Source/WebCore/page/Chrome.cpp index 533caeb644ef..d3069cee1378 100644 --- a/Source/WebCore/page/Chrome.cpp +++ b/Source/WebCore/page/Chrome.cpp @@ -406,7 +406,7 @@ bool Chrome::print(Frame& frame) return false; } - m_client.print(frame); + m_client.print(frame, frame.document()->titleWithDirection()); return true; } diff --git a/Source/WebCore/page/ChromeClient.h b/Source/WebCore/page/ChromeClient.h index 84054f22ef43..cf2b3f0d9aba 100644 --- a/Source/WebCore/page/ChromeClient.h +++ b/Source/WebCore/page/ChromeClient.h @@ -222,7 +222,7 @@ class ChromeClient { virtual void unavailablePluginButtonClicked(Element&, RenderEmbeddedObject::PluginUnavailabilityReason) const { } virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags, const String& toolTip, TextDirection) = 0; - virtual void print(Frame&) = 0; + virtual void print(Frame&, const StringWithDirection&) = 0; virtual Color underlayColor() const { return Color(); } diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog index 0ac7687f1086..ee317ac67097 100644 --- a/Source/WebKit/ChangeLog +++ b/Source/WebKit/ChangeLog @@ -1,3 +1,20 @@ +2021-02-10 Rob Buis + + Use event loop to set title + https://bugs.webkit.org/show_bug.cgi?id=218496 + + Reviewed by Darin Adler. + + Add title parameter to PrintFrame message. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::printFrame): + * UIProcess/WebPageProxy.h: + * UIProcess/WebPageProxy.messages.in: + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + (WebKit::WebChromeClient::print): + * WebProcess/WebCoreSupport/WebChromeClient.h: + 2021-02-10 Myles C. Maxfield Move pal/spi/cocoa/CoreTextSPI.h to pal/spi/cf/CoreTextSPI.h diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp index 6987277bb1bd..cd3bacc23065 100644 --- a/Source/WebKit/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit/UIProcess/WebPageProxy.cpp @@ -5917,7 +5917,7 @@ void WebPageProxy::showContactPicker(const WebCore::ContactsRequestData& request pageClient().showContactPicker(requestData, WTFMove(completionHandler)); } -void WebPageProxy::printFrame(FrameIdentifier frameID, CompletionHandler&& completionHandler) +void WebPageProxy::printFrame(FrameIdentifier frameID, const String& title, CompletionHandler&& completionHandler) { ASSERT(!m_isPerformingDOMPrintOperation); m_isPerformingDOMPrintOperation = true; @@ -5925,6 +5925,8 @@ void WebPageProxy::printFrame(FrameIdentifier frameID, CompletionHandler WebFrameProxy* frame = m_process->webFrame(frameID); MESSAGE_CHECK(m_process, frame); + frame->didChangeTitle(title); + m_uiClient->printFrame(*this, *frame, [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)] () mutable { endPrinting(); // Send a message synchronously while m_isPerformingDOMPrintOperation is still true. m_isPerformingDOMPrintOperation = false; diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h index 6a42143e9076..f4c39eb8e543 100644 --- a/Source/WebKit/UIProcess/WebPageProxy.h +++ b/Source/WebKit/UIProcess/WebPageProxy.h @@ -1980,7 +1980,7 @@ class WebPageProxy : public API::ObjectImpl bool didChooseFilesForOpenPanelWithImageTranscoding(const Vector& fileURLs, const Vector& allowedMIMETypes); void showShareSheet(const WebCore::ShareDataWithParsedURL&, CompletionHandler&&); void showContactPicker(const WebCore::ContactsRequestData&, CompletionHandler>&&)>&&); - void printFrame(WebCore::FrameIdentifier, CompletionHandler&&); + void printFrame(WebCore::FrameIdentifier, const String&, CompletionHandler&&); void exceededDatabaseQuota(WebCore::FrameIdentifier, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, Messages::WebPageProxy::ExceededDatabaseQuotaDelayedReply&&); void reachedApplicationCacheOriginQuota(const String& originIdentifier, uint64_t currentQuota, uint64_t totalBytesNeeded, Messages::WebPageProxy::ReachedApplicationCacheOriginQuotaDelayedReply&&); diff --git a/Source/WebKit/UIProcess/WebPageProxy.messages.in b/Source/WebKit/UIProcess/WebPageProxy.messages.in index 649f8e12a880..4919bc988e9c 100644 --- a/Source/WebKit/UIProcess/WebPageProxy.messages.in +++ b/Source/WebKit/UIProcess/WebPageProxy.messages.in @@ -70,7 +70,7 @@ messages -> WebPageProxy { RunOpenPanel(WebCore::FrameIdentifier frameID, struct WebKit::FrameInfoData frameInfo, struct WebCore::FileChooserSettings parameters) ShowShareSheet(struct WebCore::ShareDataWithParsedURL shareData) -> (bool granted) Async ShowContactPicker(struct WebCore::ContactsRequestData requestData) -> (Optional> info) Async - PrintFrame(WebCore::FrameIdentifier frameID) -> () Synchronous + PrintFrame(WebCore::FrameIdentifier frameID, String title) -> () Synchronous RunModal() NotifyScrollerThumbIsVisibleInRect(WebCore::IntRect scrollerThumb) RecommendedScrollbarStyleDidChange(int32_t newStyle) diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp index a965e5cc4deb..c09a27b7e7f5 100644 --- a/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp +++ b/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp @@ -708,7 +708,9 @@ void WebChromeClient::mouseDidMoveOverElement(const HitTestResult& hitTestResult m_page.send(Messages::WebPageProxy::MouseDidMoveOverElement(webHitTestResultData, modifierFlags, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } -void WebChromeClient::print(Frame& frame) +static constexpr unsigned maxTitleLength = 1000; // Closest power of 10 above the W3C recommendation for Title length. + +void WebChromeClient::print(Frame& frame, const StringWithDirection& title) { WebFrame* webFrame = WebFrame::fromCoreFrame(frame); ASSERT(webFrame); @@ -733,7 +735,8 @@ void WebChromeClient::print(Frame& frame) } #endif - m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply()); + auto truncatedTitle = truncateFromEnd(title, maxTitleLength); + m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::PrintFrame(webFrame->frameID(), truncatedTitle.string), Messages::WebPageProxy::PrintFrame::Reply()); } void WebChromeClient::exceededDatabaseQuota(Frame& frame, const String& databaseName, DatabaseDetails details) diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h b/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h index 8c12a5c7c00e..014bdcf39365 100644 --- a/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h +++ b/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h @@ -140,7 +140,7 @@ class WebChromeClient final : public WebCore::ChromeClient { void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags, const String& toolTip, WebCore::TextDirection) final; - void print(WebCore::Frame&) final; + void print(WebCore::Frame&, const WebCore::StringWithDirection&) final; void exceededDatabaseQuota(WebCore::Frame&, const String& databaseName, WebCore::DatabaseDetails) final; diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog index a62f53e60d8a..a7e261557e80 100644 --- a/Source/WebKitLegacy/mac/ChangeLog +++ b/Source/WebKitLegacy/mac/ChangeLog @@ -1,3 +1,16 @@ +2021-02-10 Rob Buis + + Use event loop to set title + https://bugs.webkit.org/show_bug.cgi?id=218496 + + Reviewed by Darin Adler. + + Adjust to API change. + + * WebCoreSupport/WebChromeClient.h: + * WebCoreSupport/WebChromeClient.mm: + (WebChromeClient::print): + 2021-02-08 Ryan Haddad Permission request API for MediaKeySystem access support diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h b/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h index b8d011fef4d2..1a66ce9dff81 100644 --- a/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h +++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h @@ -122,7 +122,7 @@ class WebChromeClient : public WebCore::ChromeClient { void setToolTip(const String&); - void print(WebCore::Frame&) final; + void print(WebCore::Frame&, const WebCore::StringWithDirection&) final; void exceededDatabaseQuota(WebCore::Frame&, const String& databaseName, WebCore::DatabaseDetails) final; void reachedMaxAppCacheSize(int64_t spaceNeeded) final; void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin&, int64_t totalSpaceNeeded) final; diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm b/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm index 73b42561f441..86afa0e9d37a 100644 --- a/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm +++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm @@ -681,7 +681,7 @@ - (void)setIsSelected:(BOOL)isSelected; [(WebHTMLView *)documentView _setToolTip:toolTip]; } -void WebChromeClient::print(Frame& frame) +void WebChromeClient::print(Frame& frame, const StringWithDirection&) { WebFrame *webFrame = kit(&frame); if ([[m_webView UIDelegate] respondsToSelector:@selector(webView:printFrame:)]) diff --git a/Source/WebKitLegacy/win/ChangeLog b/Source/WebKitLegacy/win/ChangeLog index fc9755664304..581340296d85 100644 --- a/Source/WebKitLegacy/win/ChangeLog +++ b/Source/WebKitLegacy/win/ChangeLog @@ -1,3 +1,16 @@ +2021-02-10 Rob Buis + + Use event loop to set title + https://bugs.webkit.org/show_bug.cgi?id=218496 + + Reviewed by Darin Adler. + + Adjust to API change. + + * WebCoreSupport/WebChromeClient.cpp: + (WebChromeClient::print): + * WebCoreSupport/WebChromeClient.h: + 2021-02-08 Brady Eidson Make the UserContentController for ServiceWorker pages be non-optional. diff --git a/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp b/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp index f745dd459c16..47d56a7a41c1 100644 --- a/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp +++ b/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp @@ -571,7 +571,7 @@ void WebChromeClient::unavailablePluginButtonClicked(Element& element, RenderEmb uiDelegatePrivate3->didPressMissingPluginButton(e.get()); } -void WebChromeClient::print(Frame& frame) +void WebChromeClient::print(Frame& frame, const StringWithDirection&) { COMPtr uiDelegate; if (SUCCEEDED(m_webView->uiDelegate(&uiDelegate))) diff --git a/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h b/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h index 96019ea85481..3198de219e89 100644 --- a/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h +++ b/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h @@ -116,7 +116,7 @@ class WebChromeClient final : public WebCore::ChromeClient { bool shouldUnavailablePluginMessageBeButton(WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const final; void unavailablePluginButtonClicked(WebCore::Element&, WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const final; - void print(WebCore::Frame&) final; + void print(WebCore::Frame&, const WebCore::StringWithDirection&) final; void exceededDatabaseQuota(WebCore::Frame&, const WTF::String&, WebCore::DatabaseDetails) final; diff --git a/Tools/ChangeLog b/Tools/ChangeLog index 0ab475c425f5..081f666b9103 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,34 @@ +2021-02-10 Rob Buis + + Use event loop to set title + https://bugs.webkit.org/show_bug.cgi?id=218496 + + Reviewed by Darin Adler. + + Adapt unit tests to wait for title change tasks + to be processed. + + * TestWebKitAPI/Tests/WebKit/PageLoadState.cpp: + (TestWebKitAPI::didChangeTitle): + (TestWebKitAPI::TEST): + * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm: + (TEST): + * TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp: + (testWebViewAuthenticationFailure): + (testWebViewAuthenticationNoCredential): + (testWebViewAuthenticationSuccess): + (testWebViewAuthenticationEmptyRealm): + * TestWebKitAPI/Tests/WebKitGLib/TestBackForwardList.cpp: + (testBackForwardListNavigation): + * TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp: + (testWebViewTitle): + * TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp: + (testLoadFailedWithTLSErrors): + * TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp: + (testWebKitSettingsJavaScriptMarkup): + * TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp: + (testWebViewTitleChange): + 2021-02-10 Jiewen Tan [WebAuthn] Produce ClientDataJSON in the SPI diff --git a/Tools/TestWebKitAPI/Tests/WebKit/PageLoadState.cpp b/Tools/TestWebKitAPI/Tests/WebKit/PageLoadState.cpp index 12e9872ccf62..51bfea29d348 100644 --- a/Tools/TestWebKitAPI/Tests/WebKit/PageLoadState.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKit/PageLoadState.cpp @@ -35,6 +35,7 @@ namespace TestWebKitAPI { static bool test1Done; +static bool titleChangeDone; struct PageLoadTestState { int didChangeActiveURL { 0 }; @@ -112,6 +113,7 @@ static void didChangeTitle(const void* clientInfo) { PageLoadTestState* state = reinterpret_cast(const_cast(clientInfo)); state->didChangeTitle++; + titleChangeDone = true; } static void didChangeWebProcessIsResponsive(const void* clientInfo) @@ -278,14 +280,14 @@ TEST(WebKit, PageLoadState) EXPECT_EQ(state.willChangeCanGoBack, 2); EXPECT_EQ(state.willChangeCanGoForward, 1); - test1Done = false; + titleChangeDone = false; url = adoptWK(Util::createURLForResource("set-long-title", "html")); WKPageLoadURL(webView.page(), url.get()); - Util::run(&test1Done); + Util::run(&titleChangeDone); EXPECT_EQ(state.didChangeActiveURL, 4); - EXPECT_EQ(state.didChangeTitle, 2); - EXPECT_EQ(state.willChangeTitle, 2); + EXPECT_EQ(state.didChangeTitle, 1); + EXPECT_EQ(state.willChangeTitle, 1); WKPageSetPageStateClient(webView.page(), nullptr); diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm index 6c7b1f574750..0eb459f31e43 100644 --- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm +++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm @@ -412,7 +412,7 @@ - (void)_webView:(WKWebView *)webView drawFooterInRect:(CGRect)rect forPageWithT auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]); auto delegate = adoptNS([[PrintDelegate alloc] init]); [webView setUIDelegate:delegate.get()]; - [webView loadHTMLString:@"test_titlehello world!" baseURL:[NSURL URLWithString:@"http://example.com/"]]; + [webView loadHTMLString:@"test_titlehello world!" baseURL:[NSURL URLWithString:@"http://example.com/"]]; TestWebKitAPI::Util::run(&done); NSPrintOperation *operation = [webView _printOperationWithPrintInfo:[NSPrintInfo sharedPrintInfo]]; diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp index c92063fb2f4f..7e2b8339e0e8 100644 --- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp @@ -196,7 +196,7 @@ static void testWebViewAuthenticationFailure(AuthenticationTest* test, gconstpoi webkit_authentication_request_authenticate(request, credential); webkit_credential_free(credential); // Expect authentication failed page. - test->waitUntilLoadFinished(); + test->waitUntilTitleChanged(); g_assert_cmpint(test->m_loadEvents.size(), ==, 3); g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted); @@ -214,7 +214,7 @@ static void testWebViewAuthenticationNoCredential(AuthenticationTest* test, gcon WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest(); webkit_authentication_request_authenticate(request, 0); // Server doesn't ask for new credentials. - test->waitUntilLoadFinished(); + test->waitUntilTitleChanged(); g_assert_cmpint(test->m_loadEvents.size(), ==, 3); g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted); @@ -290,7 +290,7 @@ static void testWebViewAuthenticationSuccess(AuthenticationTest* test, gconstpoi WebKitCredential* credential = webkit_credential_new(authTestUsername, authTestPassword, WEBKIT_CREDENTIAL_PERSISTENCE_FOR_SESSION); webkit_authentication_request_authenticate(request, credential); webkit_credential_free(credential); - test->waitUntilLoadFinished(); + test->waitUntilTitleChanged(); g_assert_cmpint(test->m_loadEvents.size(), ==, 3); g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted); @@ -304,6 +304,7 @@ static void testWebViewAuthenticationSuccess(AuthenticationTest* test, gconstpoi test->loadURI(kServer->getURIForPath("/auth-test.html").data()); // There is no authentication challenge. test->waitUntilLoadFinished(); + test->waitUntilTitleChanged(); g_assert_cmpint(test->m_loadEvents.size(), ==, 3); g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted); @@ -321,7 +322,7 @@ static void testWebViewAuthenticationEmptyRealm(AuthenticationTest* test, gconst WebKitCredential* credential = webkit_credential_new(authTestUsername, authTestPassword, WEBKIT_CREDENTIAL_PERSISTENCE_FOR_SESSION); webkit_authentication_request_authenticate(request, credential); webkit_credential_free(credential); - test->waitUntilLoadFinished(); + test->waitUntilTitleChanged(); g_assert_cmpint(test->m_loadEvents.size(), ==, 3); g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted); diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestBackForwardList.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestBackForwardList.cpp index 85d2fc022a01..56ac4a09963b 100644 --- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestBackForwardList.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestBackForwardList.cpp @@ -169,6 +169,7 @@ static void testBackForwardListNavigation(BackForwardListTest* test, gconstpoint test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem; test->loadURI(uriPage1.data()); test->waitUntilLoadFinished(); + test->waitUntilTitleChanged(); g_assert_false(webkit_web_view_can_go_back(test->m_webView)); g_assert_false(webkit_web_view_can_go_forward(test->m_webView)); @@ -186,6 +187,7 @@ static void testBackForwardListNavigation(BackForwardListTest* test, gconstpoint test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem; test->loadURI(uriPage2.data()); test->waitUntilLoadFinished(); + test->waitUntilTitleChanged(); g_assert_true(webkit_web_view_can_go_back(test->m_webView)); g_assert_false(webkit_web_view_can_go_forward(test->m_webView)); diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp index 9b98fe408119..6a5ca6635028 100644 --- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp @@ -155,7 +155,7 @@ static void testWebViewTitle(LoadTrackingTest* test, gconstpointer) { g_assert_null(webkit_web_view_get_title(test->m_webView)); test->loadHtml("Welcome to WebKit-GTK+!", 0); - test->waitUntilLoadFinished(); + test->waitUntilTitleChanged(); g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, "Welcome to WebKit-GTK+!"); } diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp index 892d342806bf..2a0a3406367e 100644 --- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp @@ -276,7 +276,7 @@ static void testLoadFailedWithTLSErrors(TLSErrorsTest* test, gconstpointer) webkit_web_context_allow_tls_certificate_for_host(test->m_webContext.get(), test->certificate(), test->host()); // The page should now load without errors. test->loadURI(kHttpsServer->getURIForPath("/test-tls/").data()); - test->waitUntilLoadFinished(); + test->waitUntilTitleChanged(); g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted); g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted); diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp index 63ef667e967f..815612dc8069 100644 --- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp @@ -452,7 +452,7 @@ static void testWebKitSettingsJavaScriptMarkup(WebViewTest* test, gconstpointer) " " ""; test->loadHtml(html, nullptr); - test->waitUntilLoadFinished(); + test->waitUntilTitleChanged(); g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, "No JavaScript allowed"); auto* jsResult = test->runJavaScriptAndWaitUntilFinished("document.getElementsByTagName('script').length", nullptr); diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp index 9edfcf63c89a..0f101bced6d4 100644 --- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp +++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp @@ -1229,15 +1229,17 @@ static void testWebViewTitleChange(WebViewTitleTest* test, gconstpointer) g_assert_cmpint(test->m_webViewTitles.size(), ==, 0); test->loadHtml("Page Title", nullptr); - test->waitUntilLoadFinished(); + test->waitUntilTitleChanged(); g_assert_cmpint(test->m_webViewTitles.size(), ==, 1); g_assert_cmpstr(test->m_webViewTitles[0].data(), ==, "Page Title"); test->loadHtml("Another Page Title", nullptr); - test->waitUntilLoadFinished(); + test->waitUntilTitleChanged(); + g_assert_cmpint(test->m_webViewTitles.size(), ==, 2); + g_assert_cmpstr(test->m_webViewTitles[1].data(), ==, ""); + test->waitUntilTitleChanged(); g_assert_cmpint(test->m_webViewTitles.size(), ==, 3); /* Page title should be immediately unset when loading a new page. */ - g_assert_cmpstr(test->m_webViewTitles[1].data(), ==, ""); g_assert_cmpstr(test->m_webViewTitles[2].data(), ==, "Another Page Title"); test->loadHtml("

This page has no title!

", nullptr); @@ -1246,11 +1248,9 @@ static void testWebViewTitleChange(WebViewTitleTest* test, gconstpointer) g_assert_cmpstr(test->m_webViewTitles[3].data(), ==, ""); test->loadHtml("", nullptr); - test->waitUntilLoadFinished(); - g_assert_cmpint(test->m_webViewTitles.size(), ==, 7); - g_assert_cmpstr(test->m_webViewTitles[4].data(), ==, "one"); - g_assert_cmpstr(test->m_webViewTitles[5].data(), ==, "two"); - g_assert_cmpstr(test->m_webViewTitles[6].data(), ==, "three"); + test->waitUntilTitleChanged(); + g_assert_cmpint(test->m_webViewTitles.size(), ==, 5); + g_assert_cmpstr(test->m_webViewTitles[4].data(), ==, "three"); } #if PLATFORM(WPE)