Title: [272707] trunk
Revision
272707
Author
commit-qu...@webkit.org
Date
2021-02-10 22:22:38 -0800 (Wed, 10 Feb 2021)

Log Message

Use event loop to set title
https://bugs.webkit.org/show_bug.cgi?id=218496

Patch by Rob Buis <rb...@igalia.com> 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:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (272706 => 272707)


--- trunk/LayoutTests/ChangeLog	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/LayoutTests/ChangeLog	2021-02-11 06:22:38 UTC (rev 272707)
@@ -1,3 +1,28 @@
+2021-02-10  Rob Buis  <rb...@igalia.com>
+
+        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  <ryanhad...@apple.com>
 
         [ Big Sur ] imported/w3c/web-platform-tests/css/css-flexbox/contain-size-layout-abspos-flex-container-crash.html is failing

Modified: trunk/LayoutTests/TestExpectations (272706 => 272707)


--- trunk/LayoutTests/TestExpectations	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/LayoutTests/TestExpectations	2021-02-11 06:22:38 UTC (rev 272707)
@@ -4743,6 +4743,3 @@
 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 ]
-

Modified: trunk/LayoutTests/fast/dom/title-text-property-2.html (272706 => 272707)


--- trunk/LayoutTests/fast/dom/title-text-property-2.html	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/LayoutTests/fast/dom/title-text-property-2.html	2021-02-11 06:22:38 UTC (rev 272707)
@@ -1,8 +1,9 @@
 <html>
 <head>
 <script>
-function runTests() {
+function startTest() {
     if (window.testRunner) {
+        testRunner.waitUntilDone();
         testRunner.dumpAsText();
         testRunner.dumpTitleChanges();
     }
@@ -10,11 +11,19 @@
     console.log("Setting document.title to TITLE1");    
     document.title = 'TITLE1';
 
+    internals.queueTask("DOMManipulation", () => continueTest());
+}
+
+function continueTest() {
     title = document.getElementsByTagName('title').item(0);
     
     console.log("Setting title element's text to TITLE2");
     title.text = 'TITLE2';
     
+    internals.queueTask("DOMManipulation", () => endTest());
+}
+
+function endTest() {
     newTitle = document.createElement('title');
     console.log("Should not set title");
     newTitle.appendChild(document.createTextNode('FAIL'));
@@ -28,10 +37,12 @@
         titleElement = titleElements[titleElements.length - 1];
         titleElement.parentNode.removeChild(titleElement);
     }
+
+    internals.queueTask("DOMManipulation", () => testRunner.notifyDone());
 }
 </script>
 <title>Initial title</title>
 </head> 
-<body _onload_="runTests();" >
+<body _onload_="startTest();" >
 </body>
 </html>

Modified: trunk/LayoutTests/fast/dom/title-text-property-assigning-empty-string.html (272706 => 272707)


--- trunk/LayoutTests/fast/dom/title-text-property-assigning-empty-string.html	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/LayoutTests/fast/dom/title-text-property-assigning-empty-string.html	2021-02-11 06:22:38 UTC (rev 272707)
@@ -1,17 +1,23 @@
 <html>
 <head>
 <script>
-function runTests() {
+function startTest() {
     if (window.testRunner) {
+        testRunner.waitUntilDone();
         testRunner.dumpAsText();
         testRunner.dumpTitleChanges();
     }
 
     document.title = 'New non-empty title';
+    internals.queueTask("DOMManipulation", () => endTest())
+}
+
+function endTest() {
     document.title = '';
+    internals.queueTask("DOMManipulation", () => testRunner.notifyDone())
 }
 </script>
 </head>
-<body _onload_='runTests();'>
+<body _onload_='startTest();'>
 </body>
 </html>

Modified: trunk/LayoutTests/fast/dom/title-text-property.html (272706 => 272707)


--- trunk/LayoutTests/fast/dom/title-text-property.html	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/LayoutTests/fast/dom/title-text-property.html	2021-02-11 06:22:38 UTC (rev 272707)
@@ -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());
 }
 </script>
 </head>

Modified: trunk/LayoutTests/http/tests/globalhistory/history-delegate-basic-title-expected.txt (272706 => 272707)


--- trunk/LayoutTests/http/tests/globalhistory/history-delegate-basic-title-expected.txt	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/LayoutTests/http/tests/globalhistory/history-delegate-basic-title-expected.txt	2021-02-11 06:22:38 UTC (rev 272707)
@@ -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.

Modified: trunk/LayoutTests/http/tests/globalhistory/history-delegate-basic-title.html (272706 => 272707)


--- trunk/LayoutTests/http/tests/globalhistory/history-delegate-basic-title.html	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/LayoutTests/http/tests/globalhistory/history-delegate-basic-title.html	2021-02-11 06:22:38 UTC (rev 272707)
@@ -1,15 +1,20 @@
 <html>
 <head>
 <script>
-if (window.testRunner)
+if (window.testRunner) {
+    testRunner.waitUntilDone();
     testRunner.dumpAsText();
+}
 </script>
 <title>Test Title 1</title>
 </head>
-<body>
+<body _onload_="runTest()">
 This test sees if the history delegate is notified of title changes.
-</body>
 <script>
+function runTest() {
 document.title = "Test Title 2";
+internals.queueTask("DOMManipulation", () => testRunner.notifyDone());
+}
 </script>
+</body>
 </html>

Modified: trunk/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt (272706 => 272707)


--- trunk/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt	2021-02-11 06:22:38 UTC (rev 272707)
@@ -5,8 +5,8 @@
 http://127.0.0.1:8000/loading/resources/basic-auth-testing.php?username=webkit&password=rocks - didReceiveAuthenticationChallenge - Responding with webkit:rocks
 frame "<!--frame1-->" - didCommitLoadForFrame
 frame "<!--frame1-->" - didFinishDocumentLoadForFrame
+frame "<!--frame1-->" - didHandleOnloadEventsForFrame
 frame "<!--frame1-->" - willPerformClientRedirectToURL: http://127.0.0.1:8000/a//b/non-existent-file.html
-frame "<!--frame1-->" - didHandleOnloadEventsForFrame
 main frame - didHandleOnloadEventsForFrame
 frame "<!--frame1-->" - didFinishLoadForFrame
 main frame - didFinishLoadForFrame
@@ -15,5 +15,6 @@
 frame "<!--frame1-->" - didCommitLoadForFrame
 frame "<!--frame1-->" - didReceiveTitle: 404 Not Found
 frame "<!--frame1-->" - didFinishDocumentLoadForFrame
-frame "<!--frame1-->" - didFailLoadWithError
+frame "<!--frame1-->" - didHandleOnloadEventsForFrame
+frame "<!--frame1-->" - didFinishLoadForFrame
 PASS did not cause assertion failure.

Modified: trunk/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes.html (272706 => 272707)


--- trunk/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes.html	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes.html	2021-02-11 06:22:38 UTC (rev 272707)
@@ -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 @@
 }
 </script>
 </head>
-<body>
-<iframe id="frame" src="" _onload_="notifyFrameDidLoad(this)"></iframe>
+<body _onload_="notifyFrameDidLoad(frame)">
+<iframe id="frame" src=""
 <p>PASS did not cause assertion failure.</p>
 </body>
 </html>

Modified: trunk/LayoutTests/http/tests/loading/redirect-with-no-location-crash-expected.txt (272706 => 272707)


--- trunk/LayoutTests/http/tests/loading/redirect-with-no-location-crash-expected.txt	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/LayoutTests/http/tests/loading/redirect-with-no-location-crash-expected.txt	2021-02-11 06:22:38 UTC (rev 272707)
@@ -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 "<!--frame1-->" - didStartProvisionalLoadForFrame
 main frame - didFinishDocumentLoadForFrame
 frame "<!--frame1-->" - didCommitLoadForFrame

Modified: trunk/LayoutTests/http/tests/loading/redirect-with-no-location-crash.html (272706 => 272707)


--- trunk/LayoutTests/http/tests/loading/redirect-with-no-location-crash.html	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/LayoutTests/http/tests/loading/redirect-with-no-location-crash.html	2021-02-11 06:22:38 UTC (rev 272707)
@@ -2,11 +2,13 @@
 <head>
     <!-- Test for https://bugs.webkit.org/show_bug.cgi?id=29293 -->
     <script>
-        if (window.testRunner)
+        if (window.testRunner) {
             testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
     </script>
 </head>
-<body>
+<body _onload_="setTimeout(function() { if (window.testRunner) testRunner.notifyDone(); })">
   <iframe src=""
 </body>
 <html>

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (272706 => 272707)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2021-02-11 06:22:38 UTC (rev 272707)
@@ -583,8 +583,6 @@
 
 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 ]

Copied: trunk/LayoutTests/platform/win/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt (from rev 272706, trunk/LayoutTests/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt) (0 => 272707)


--- trunk/LayoutTests/platform/win/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/win/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt	2021-02-11 06:22:38 UTC (rev 272707)
@@ -0,0 +1,20 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+frame "<!--frame1-->" - 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 "<!--frame1-->" - didCommitLoadForFrame
+frame "<!--frame1-->" - didFinishDocumentLoadForFrame
+frame "<!--frame1-->" - didHandleOnloadEventsForFrame
+frame "<!--frame1-->" - willPerformClientRedirectToURL: http://127.0.0.1:8000/a//b/non-existent-file.html
+main frame - didHandleOnloadEventsForFrame
+frame "<!--frame1-->" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+frame "<!--frame1-->" - didStartProvisionalLoadForFrame
+frame "<!--frame1-->" - didCancelClientRedirectForFrame
+frame "<!--frame1-->" - didCommitLoadForFrame
+frame "<!--frame1-->" - didFinishDocumentLoadForFrame
+frame "<!--frame1-->" - didHandleOnloadEventsForFrame
+frame "<!--frame1-->" - didFinishLoadForFrame
+frame "<!--frame1-->" - didReceiveTitle: 404 Not Found
+PASS did not cause assertion failure.

Modified: trunk/LayoutTests/platform/wk2/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt (272706 => 272707)


--- trunk/LayoutTests/platform/wk2/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/LayoutTests/platform/wk2/http/tests/loading/basic-auth-load-URL-with-consecutive-slashes-expected.txt	2021-02-11 06:22:38 UTC (rev 272707)
@@ -5,8 +5,8 @@
 127.0.0.1:8000 - didReceiveAuthenticationChallenge - ProtectionSpaceAuthenticationSchemeHTTPBasic - Responding with webkit:rocks
 frame "<!--frame1-->" - didCommitLoadForFrame
 frame "<!--frame1-->" - didFinishDocumentLoadForFrame
+frame "<!--frame1-->" - didHandleOnloadEventsForFrame
 frame "<!--frame1-->" - willPerformClientRedirectToURL: http://127.0.0.1:8000/a//b/non-existent-file.html
-frame "<!--frame1-->" - didHandleOnloadEventsForFrame
 main frame - didHandleOnloadEventsForFrame
 frame "<!--frame1-->" - didFinishLoadForFrame
 main frame - didFinishLoadForFrame
@@ -13,7 +13,8 @@
 frame "<!--frame1-->" - didStartProvisionalLoadForFrame
 frame "<!--frame1-->" - didCancelClientRedirectForFrame
 frame "<!--frame1-->" - didCommitLoadForFrame
+frame "<!--frame1-->" - didFinishDocumentLoadForFrame
+frame "<!--frame1-->" - didHandleOnloadEventsForFrame
+frame "<!--frame1-->" - didFinishLoadForFrame
 frame "<!--frame1-->" - didReceiveTitle: 404 Not Found
-frame "<!--frame1-->" - didFinishDocumentLoadForFrame
-frame "<!--frame1-->" - didFailLoadWithError
 PASS did not cause assertion failure.

Modified: trunk/LayoutTests/platform/wk2/http/tests/loading/redirect-with-no-location-crash-expected.txt (272706 => 272707)


--- trunk/LayoutTests/platform/wk2/http/tests/loading/redirect-with-no-location-crash-expected.txt	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/LayoutTests/platform/wk2/http/tests/loading/redirect-with-no-location-crash-expected.txt	2021-02-11 06:22:38 UTC (rev 272707)
@@ -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 "<!--frame1-->" - didStartProvisionalLoadForFrame
 frame "<!--frame1-->" - didCommitLoadForFrame

Modified: trunk/Source/WebCore/ChangeLog (272706 => 272707)


--- trunk/Source/WebCore/ChangeLog	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebCore/ChangeLog	2021-02-11 06:22:38 UTC (rev 272707)
@@ -1,3 +1,24 @@
+2021-02-10  Rob Buis  <rb...@igalia.com>
+
+        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  <mmaxfi...@apple.com>
 
         Move pal/spi/cocoa/CoreTextSPI.h to pal/spi/cf/CoreTextSPI.h

Modified: trunk/Source/WebCore/dom/Document.cpp (272706 => 272707)


--- trunk/Source/WebCore/dom/Document.cpp	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebCore/dom/Document.cpp	2021-02-11 06:22:38 UTC (rev 272707)
@@ -1687,8 +1687,14 @@
     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()

Modified: trunk/Source/WebCore/dom/Document.h (272706 => 272707)


--- trunk/Source/WebCore/dom/Document.h	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebCore/dom/Document.h	2021-02-11 06:22:38 UTC (rev 272707)
@@ -924,6 +924,7 @@
     // 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 @@
     bool m_didDispatchViewportPropertiesChanged { false };
 #endif
 
+    bool m_updateTitleTaskScheduled { false };
+
     OrientationNotifier m_orientationNotifier;
     mutable RefPtr<Logger> m_logger;
     RefPtr<StringCallback> m_consoleMessageListener;

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (272706 => 272707)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2021-02-11 06:22:38 UTC (rev 272707)
@@ -1721,7 +1721,8 @@
 
     frameLoader()->willChangeTitle(this);
     m_pageTitle = title;
-    frameLoader()->didChangeTitle(this);
+    if (frameLoader())
+        frameLoader()->didChangeTitle(this);
 }
 
 URL DocumentLoader::urlForHistory() const

Modified: trunk/Source/WebCore/loader/EmptyClients.h (272706 => 272707)


--- trunk/Source/WebCore/loader/EmptyClients.h	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebCore/loader/EmptyClients.h	2021-02-11 06:22:38 UTC (rev 272707)
@@ -125,7 +125,7 @@
 
     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 { }
 

Modified: trunk/Source/WebCore/page/Chrome.cpp (272706 => 272707)


--- trunk/Source/WebCore/page/Chrome.cpp	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebCore/page/Chrome.cpp	2021-02-11 06:22:38 UTC (rev 272707)
@@ -406,7 +406,7 @@
         return false;
     }
 
-    m_client.print(frame);
+    m_client.print(frame, frame.document()->titleWithDirection());
     return true;
 }
 

Modified: trunk/Source/WebCore/page/ChromeClient.h (272706 => 272707)


--- trunk/Source/WebCore/page/ChromeClient.h	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebCore/page/ChromeClient.h	2021-02-11 06:22:38 UTC (rev 272707)
@@ -222,7 +222,7 @@
     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(); }
 

Modified: trunk/Source/WebKit/ChangeLog (272706 => 272707)


--- trunk/Source/WebKit/ChangeLog	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebKit/ChangeLog	2021-02-11 06:22:38 UTC (rev 272707)
@@ -1,3 +1,20 @@
+2021-02-10  Rob Buis  <rb...@igalia.com>
+
+        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  <mmaxfi...@apple.com>
 
         Move pal/spi/cocoa/CoreTextSPI.h to pal/spi/cf/CoreTextSPI.h

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (272706 => 272707)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-02-11 06:22:38 UTC (rev 272707)
@@ -5917,7 +5917,7 @@
     pageClient().showContactPicker(requestData, WTFMove(completionHandler));
 }
     
-void WebPageProxy::printFrame(FrameIdentifier frameID, CompletionHandler<void()>&& completionHandler)
+void WebPageProxy::printFrame(FrameIdentifier frameID, const String& title, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(!m_isPerformingDOMPrintOperation);
     m_isPerformingDOMPrintOperation = true;
@@ -5925,6 +5925,8 @@
     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;

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (272706 => 272707)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-02-11 06:22:38 UTC (rev 272707)
@@ -1980,7 +1980,7 @@
     bool didChooseFilesForOpenPanelWithImageTranscoding(const Vector<String>& fileURLs, const Vector<String>& allowedMIMETypes);
     void showShareSheet(const WebCore::ShareDataWithParsedURL&, CompletionHandler<void(bool)>&&);
     void showContactPicker(const WebCore::ContactsRequestData&, CompletionHandler<void(Optional<Vector<WebCore::ContactInfo>>&&)>&&);
-    void printFrame(WebCore::FrameIdentifier, CompletionHandler<void()>&&);
+    void printFrame(WebCore::FrameIdentifier, const String&, CompletionHandler<void()>&&);
     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&&);
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (272706 => 272707)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-02-11 06:22:38 UTC (rev 272707)
@@ -70,7 +70,7 @@
     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<Vector<WebCore::ContactInfo>> info) Async
-    PrintFrame(WebCore::FrameIdentifier frameID) -> () Synchronous
+    PrintFrame(WebCore::FrameIdentifier frameID, String title) -> () Synchronous
     RunModal()
     NotifyScrollerThumbIsVisibleInRect(WebCore::IntRect scrollerThumb)
     RecommendedScrollbarStyleDidChange(int32_t newStyle)

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (272706 => 272707)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2021-02-11 06:22:38 UTC (rev 272707)
@@ -708,7 +708,9 @@
     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 @@
     }
 #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)

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (272706 => 272707)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2021-02-11 06:22:38 UTC (rev 272707)
@@ -140,7 +140,7 @@
 
     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;
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (272706 => 272707)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2021-02-11 06:22:38 UTC (rev 272707)
@@ -1,3 +1,16 @@
+2021-02-10  Rob Buis  <rb...@igalia.com>
+
+        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  <ryanhad...@apple.com>
 
         Permission request API for MediaKeySystem access support

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h (272706 => 272707)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h	2021-02-11 06:22:38 UTC (rev 272707)
@@ -122,7 +122,7 @@
 
     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;

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm (272706 => 272707)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm	2021-02-11 06:22:38 UTC (rev 272707)
@@ -681,7 +681,7 @@
         [(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:)])

Modified: trunk/Source/WebKitLegacy/win/ChangeLog (272706 => 272707)


--- trunk/Source/WebKitLegacy/win/ChangeLog	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebKitLegacy/win/ChangeLog	2021-02-11 06:22:38 UTC (rev 272707)
@@ -1,3 +1,16 @@
+2021-02-10  Rob Buis  <rb...@igalia.com>
+
+        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  <beid...@apple.com>
 
         Make the UserContentController for ServiceWorker pages be non-optional.

Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp (272706 => 272707)


--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp	2021-02-11 06:22:38 UTC (rev 272707)
@@ -571,7 +571,7 @@
     uiDelegatePrivate3->didPressMissingPluginButton(e.get());
 }
 
-void WebChromeClient::print(Frame& frame)
+void WebChromeClient::print(Frame& frame, const StringWithDirection&)
 {
     COMPtr<IWebUIDelegate> uiDelegate;
     if (SUCCEEDED(m_webView->uiDelegate(&uiDelegate)))

Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h (272706 => 272707)


--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h	2021-02-11 06:22:38 UTC (rev 272707)
@@ -116,7 +116,7 @@
     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;
 

Modified: trunk/Tools/ChangeLog (272706 => 272707)


--- trunk/Tools/ChangeLog	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Tools/ChangeLog	2021-02-11 06:22:38 UTC (rev 272707)
@@ -1,3 +1,34 @@
+2021-02-10  Rob Buis  <rb...@igalia.com>
+
+        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  <jiewen_...@apple.com>
 
         [WebAuthn] Produce ClientDataJSON in the SPI

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit/PageLoadState.cpp (272706 => 272707)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/PageLoadState.cpp	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/PageLoadState.cpp	2021-02-11 06:22:38 UTC (rev 272707)
@@ -35,6 +35,7 @@
 namespace TestWebKitAPI {
 
 static bool test1Done;
+static bool titleChangeDone;
 
 struct PageLoadTestState {
     int didChangeActiveURL { 0 };
@@ -112,6 +113,7 @@
 {
     PageLoadTestState* state = reinterpret_cast<PageLoadTestState*>(const_cast<void*>(clientInfo));
     state->didChangeTitle++;
+    titleChangeDone = true;
 }
 
 static void didChangeWebProcessIsResponsive(const void* clientInfo)
@@ -278,14 +280,14 @@
     EXPECT_EQ(state.willChangeCanGoBack, 2);
     EXPECT_EQ(state.willChangeCanGoForward, 1);
 
-    test1Done = false;
+    titleChangeDone = false;
     url = "" "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);
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm (272706 => 272707)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm	2021-02-11 06:22:38 UTC (rev 272707)
@@ -412,7 +412,7 @@
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
     auto delegate = adoptNS([[PrintDelegate alloc] init]);
     [webView setUIDelegate:delegate.get()];
-    [webView loadHTMLString:@"<head><title>test_title</title></head><body _onload_='print()'>hello world!</body>" baseURL:[NSURL URLWithString:@"http://example.com/"]];
+    [webView loadHTMLString:@"<head><title>test_title</title></head><body _onload_='setTimeout(function() { print() });'>hello world!</body>" baseURL:[NSURL URLWithString:@"http://example.com/"]];
     TestWebKitAPI::Util::run(&done);
 
     NSPrintOperation *operation = [webView _printOperationWithPrintInfo:[NSPrintInfo sharedPrintInfo]];

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp (272706 => 272707)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp	2021-02-11 06:22:38 UTC (rev 272707)
@@ -196,7 +196,7 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestBackForwardList.cpp (272706 => 272707)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestBackForwardList.cpp	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestBackForwardList.cpp	2021-02-11 06:22:38 UTC (rev 272707)
@@ -169,6 +169,7 @@
     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 @@
     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));

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp (272706 => 272707)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp	2021-02-11 06:22:38 UTC (rev 272707)
@@ -155,7 +155,7 @@
 {
     g_assert_null(webkit_web_view_get_title(test->m_webView));
     test->loadHtml("<html><head><title>Welcome to WebKit-GTK+!</title></head></html>", 0);
-    test->waitUntilLoadFinished();
+    test->waitUntilTitleChanged();
     g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, "Welcome to WebKit-GTK+!");
 }
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp (272706 => 272707)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp	2021-02-11 06:22:38 UTC (rev 272707)
@@ -276,7 +276,7 @@
     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);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp (272706 => 272707)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp	2021-02-11 06:22:38 UTC (rev 272707)
@@ -452,7 +452,7 @@
         " </body>"
         "</html>";
     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);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp (272706 => 272707)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp	2021-02-11 05:28:46 UTC (rev 272706)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp	2021-02-11 06:22:38 UTC (rev 272707)
@@ -1229,15 +1229,17 @@
     g_assert_cmpint(test->m_webViewTitles.size(), ==, 0);
 
     test->loadHtml("<head><title>Page Title</title></head>", 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("<head><title>Another Page Title</title></head>", 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("<p>This page has no title!</p>", nullptr);
@@ -1246,11 +1248,9 @@
     g_assert_cmpstr(test->m_webViewTitles[3].data(), ==, "");
 
     test->loadHtml("<script>document.title = 'one'; document.title = 'two'; document.title = 'three';</script>", 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)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to