WebKit Bugzilla
Attachment 341608 Details for
Bug 186111
: REGRESSION (r224684): User-agent seen by page does not change when modified by the develop menu options after reloading
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186111-20180530150935.patch (text/plain), 12.78 KB, created by
Brady Eidson
on 2018-05-30 15:09:36 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Brady Eidson
Created:
2018-05-30 15:09:36 PDT
Size:
12.78 KB
patch
obsolete
>Subversion Revision: 232259 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index bc0ea74ecb7dc89c21a3c320b511504c1e2f43df..93a84b1b155a6554660dc2556332166bdeba11d2 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2018-05-30 Brady Eidson <beidson@apple.com> >+ >+ REGRESSION (r224684): User-agent seen by page does not change when modified by the develop menu options after reloading. >+ <rdar://problem/34918109> and https://bugs.webkit.org/show_bug.cgi?id=186111 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test: http/tests/navigation/useragent-reload.php >+ >+ * Modules/websockets/WebSocketHandshake.cpp: >+ (WebCore::WebSocketHandshake::clientHandshakeRequest const): Use setUserAgent() for consistency. >+ >+ * loader/DocumentLoader.cpp: >+ (WebCore::DocumentLoader::startLoadingMainResource): Clear the user agent from the original DocumentLoader request >+ before adding additional fields, as reloads should pick up user agent changes. >+ > 2018-05-29 Nan Wang <n_wang@apple.com> > > AX: setValue on contenteditable should preserve whitespace >diff --git a/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp b/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp >index 9f81e0692eba107f37eb96ec549d15fe3d247afc..b4c1b2b932c35ecd37b1f00e9c04a315e6f48fb8 100644 >--- a/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp >+++ b/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp >@@ -259,7 +259,7 @@ ResourceRequest WebSocketHandshake::clientHandshakeRequest() const > request.setHTTPHeaderField(HTTPHeaderName::SecWebSocketExtensions, extensionValue); > > // Add a User-Agent header. >- request.setHTTPHeaderField(HTTPHeaderName::UserAgent, m_document->userAgent(m_document->url())); >+ request.setHTTPUserAgent(m_document->userAgent(m_document->url())); > > return request; > } >diff --git a/Source/WebCore/loader/DocumentLoader.cpp b/Source/WebCore/loader/DocumentLoader.cpp >index 7ed4f64c921181e48af9bd603259eed55d1b883a..a6e4a01dbc4c3d9564afd20ab882ef5d275cd43d 100644 >--- a/Source/WebCore/loader/DocumentLoader.cpp >+++ b/Source/WebCore/loader/DocumentLoader.cpp >@@ -1690,12 +1690,9 @@ void DocumentLoader::startLoadingMainResource(ShouldContinue shouldContinue) > m_contentFilter = !m_substituteData.isValid() ? ContentFilter::create(*this) : nullptr; > #endif > >- // FIXME: Is there any way the extra fields could have not been added by now? >- // If not, it would be great to remove this line of code. >- // Note that currently, some requests may have incorrect extra fields even if this function has been called, >- // because we pass a wrong loadType (see FIXME in addExtraFieldsToMainResourceRequest()). >- // If we remove this line of code then ResourceRequestBase does not need to track whether isSameSite >- // is unspecified. >+ // Make sure we re-apply the user agent to the Document's ResourceRequest upon reload in case the embedding >+ // application has changed it. >+ m_request.clearHTTPUserAgent(); > frameLoader()->addExtraFieldsToMainResourceRequest(m_request); > > ASSERT(timing().startTime()); >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 5a25e5739a5bfd6af7e7a5b84bbb0e4c0ce3e826..df172c887f0353a51e760c27c4c429976269be47 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,19 @@ >+2018-05-30 Brady Eidson <beidson@apple.com> >+ >+ REGRESSION (r224684): User-agent seen by page does not change when modified by the develop menu options after reloading. >+ <rdar://problem/34918109> and https://bugs.webkit.org/show_bug.cgi?id=186111 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: >+ * WebKitTestRunner/InjectedBundle/TestRunner.cpp: >+ (WTR::TestRunner::setCustomUserAgent): >+ * WebKitTestRunner/InjectedBundle/TestRunner.h: >+ * WebKitTestRunner/TestController.cpp: >+ (WTR::TestController::resetStateToConsistentValues): >+ * WebKitTestRunner/TestInvocation.cpp: >+ (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): >+ > 2018-05-29 Sihui Liu <sihui_liu@apple.com> > > Unable to remove IndexedDB Databases with Cocoa API removeDataOfTypes >diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl >index 7baa85404da912ccce64b7c6eada4296266b86a9..4e3fd3cd1e1406bdf73b4451db04cec80e3a1b9e 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl >+++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl >@@ -323,6 +323,7 @@ interface TestRunner { > > void setWebRTCLegacyAPIEnabled(boolean value); > void setMDNSICECandidatesEnabled(boolean value); >+ void setCustomUserAgent(DOMString userAgent); > > void terminateNetworkProcess(); > void terminateServiceWorkerProcess(); >diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >index db8f2ff81174484afe546ca23ba78e3bfffeff02..95ffbae7fe625cfa1cc8535830ad9e6983e6dd1a 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >@@ -439,6 +439,12 @@ void TestRunner::setMDNSICECandidatesEnabled(bool enabled) > WKBundleOverrideBoolPreferenceForTestRunner(injectedBundle.bundle(), injectedBundle.pageGroup(), key.get(), enabled); > } > >+void TestRunner::setCustomUserAgent(JSStringRef userAgent) >+{ >+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetCustomUserAgent")); >+ WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), toWK(userAgent).get(), nullptr); >+} >+ > void TestRunner::setWebRTCLegacyAPIEnabled(bool enabled) > { > WKRetainPtr<WKStringRef> key(AdoptWK, WKStringCreateWithUTF8CString("WebKitWebRTCLegacyAPIEnabled")); >diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h >index bb6ab44978259e9550bf080dd0a16b3141667c1f..41883ceec6a0a3b852c20f1751097a04bdc6238e 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h >+++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h >@@ -131,6 +131,7 @@ public: > void setMediaDevicesEnabled(bool); > void setWebRTCLegacyAPIEnabled(bool); > void setMDNSICECandidatesEnabled(bool); >+ void setCustomUserAgent(JSStringRef); > > // Special DOM functions. > void clearBackForwardList(); >diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp >index bc34c3d8bb20f13a0f4419cce44c328393aa95ec..2ac9ec60a7588eca006ab73d1714a6e8b5ff4005 100644 >--- a/Tools/WebKitTestRunner/TestController.cpp >+++ b/Tools/WebKitTestRunner/TestController.cpp >@@ -786,6 +786,8 @@ bool TestController::resetStateToConsistentValues(const TestOptions& options) > // FIXME: We should be testing the default. > WKPageSetBackgroundExtendsBeyondPage(m_mainWebView->page(), false); > >+ WKPageSetCustomUserAgent(m_mainWebView->page(), nullptr); >+ > WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("Reset")); > WKRetainPtr<WKMutableDictionaryRef> resetMessageBody = adoptWK(WKMutableDictionaryCreate()); > >diff --git a/Tools/WebKitTestRunner/TestInvocation.cpp b/Tools/WebKitTestRunner/TestInvocation.cpp >index f199f7ec85bf1af920eb79c83f3c79e1d3e5b4b8..94c8a2d967e5ddf0e82d554167583839d0e89621 100644 >--- a/Tools/WebKitTestRunner/TestInvocation.cpp >+++ b/Tools/WebKitTestRunner/TestInvocation.cpp >@@ -877,6 +877,12 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB > return nullptr; > } > >+ if (WKStringIsEqualToUTF8CString(messageName, "SetCustomUserAgent")) { >+ WKStringRef userAgent = static_cast<WKStringRef>(messageBody); >+ WKPageSetCustomUserAgent(TestController::singleton().mainWebView()->page(), userAgent); >+ return nullptr; >+ } >+ > if (WKStringIsEqualToUTF8CString(messageName, "SetStorageAccessAPIEnabled")) { > WKBooleanRef accept = static_cast<WKBooleanRef>(messageBody); > WKCookieManagerSetStorageAccessAPIEnabled(WKContextGetCookieManager(TestController::singleton().context()), WKBooleanGetValue(accept)); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 2d4ecbe31cd40da170aa132f8ad69ccef6070634..9aec9c326dcd6c7432060f3acb3e47def8a8c752 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,17 @@ >+2018-05-30 Brady Eidson <beidson@apple.com> >+ >+ REGRESSION (r224684): User-agent seen by page does not change when modified by the develop menu options after reloading. >+ <rdar://problem/34918109> and https://bugs.webkit.org/show_bug.cgi?id=186111 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestExpectations: Skip in WK1 >+ * platform/wk2/TestExpectations: Enable in WK2 >+ >+ * http/tests/navigation/resources/user-agent-script.php: Added. >+ * http/tests/navigation/useragent-reload-expected.txt: Added. >+ * http/tests/navigation/useragent-reload.php: Added. >+ > 2018-05-29 Nan Wang <n_wang@apple.com> > > AX: setValue on contenteditable should preserve whitespace >diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations >index 3f5827663f4853813c17431dba6ca0d7ba3ba4c1..fb9b3a21569d1d2c77756b8001c226372ca9a1ef 100644 >--- a/LayoutTests/TestExpectations >+++ b/LayoutTests/TestExpectations >@@ -117,6 +117,7 @@ http/tests/loading/resourceLoadStatistics/ [ Skip ] > http/tests/resourceLoadStatistics/ [ Skip ] > http/tests/storageAccess/ [ Skip ] > http/tests/navigation/process-swap-window-open.html [ Skip ] >+http/tests/navigation/useragent-reload.php [ Skip ] > > # Only Mac and iOS have an implementation of UIScriptController::doAsyncTask(). > fast/harness/uiscriptcontroller [ Skip ] >diff --git a/LayoutTests/http/tests/navigation/resources/user-agent-script.php b/LayoutTests/http/tests/navigation/resources/user-agent-script.php >new file mode 100644 >index 0000000000000000000000000000000000000000..aeeaabc9691fe330b81d9fd7bbf4e144f7307538 >--- /dev/null >+++ b/LayoutTests/http/tests/navigation/resources/user-agent-script.php >@@ -0,0 +1,6 @@ >+<?php >+ header('Content-Type: application/javascript'); >+?> >+window.subresourceUserAgent = "<?php >+echo $_SERVER['HTTP_USER_AGENT']; >+?>"; >diff --git a/LayoutTests/http/tests/navigation/useragent-reload-expected.txt b/LayoutTests/http/tests/navigation/useragent-reload-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..863339fb8ced63ccd812aa9ad0e7ba95bf830600 >--- /dev/null >+++ b/LayoutTests/http/tests/navigation/useragent-reload-expected.txt >@@ -0,0 +1 @@ >+Passed >diff --git a/LayoutTests/http/tests/navigation/useragent-reload.php b/LayoutTests/http/tests/navigation/useragent-reload.php >new file mode 100644 >index 0000000000000000000000000000000000000000..68b7310485af7e624f474650e1209045711198a3 >--- /dev/null >+++ b/LayoutTests/http/tests/navigation/useragent-reload.php >@@ -0,0 +1,40 @@ >+<body> >+</body> >+<script> >+if (window.testRunner) { >+ testRunner.dumpAsText(); >+} else { >+ alert("Test can only be run in WebKitTestRunner"); >+} >+</script> >+<script src="resources/user-agent-script.php"></script> >+<script> >+window.mainResourceUserAgent = "<?php >+echo $_SERVER['HTTP_USER_AGENT']; >+?>"; >+ >+if (!sessionStorage.savedUserAgent) { >+ sessionStorage.savedUserAgent = navigator.userAgent; >+ testRunner.setCustomUserAgent("WebKitRules"); >+ testRunner.queueReload(); >+} else { >+ errorFound = false; >+ if (mainResourceUserAgent != subresourceUserAgent) { >+ errorFound = true; >+ document.body.innerHTML = "Error: Main resource and subresource were fetched with different user agent strings."; >+ } >+ if (mainResourceUserAgent == sessionStorage.savedUserAgent) { >+ errorFound = true; >+ document.body.innerHTML += "Error: Main resource was fetched with the same user agent string on the reload as was used on the first load."; >+ } >+ if (subresourceUserAgent == sessionStorage.savedUserAgent) { >+ errorFound = true; >+ document.body.innerHTML += "Error: Subresource was fetched with the same user agent string on the reload as was used on the first load."; >+ } >+ >+ if (!errorFound) >+ document.body.innerHTML = "Passed"; >+ >+ testRunner.notifyDone(); >+} >+</script> >diff --git a/LayoutTests/platform/wk2/TestExpectations b/LayoutTests/platform/wk2/TestExpectations >index 5a5614f25b72d67905b5935ec92168b91445ca0d..4fa1a406f01827ffb80272ee6e1bf8203c4ec520 100644 >--- a/LayoutTests/platform/wk2/TestExpectations >+++ b/LayoutTests/platform/wk2/TestExpectations >@@ -713,6 +713,8 @@ http/tests/navigation/process-swap-window-open.html [ Pass ] > # Cross-Origin-Resource-Policy response header is only implemented in WebKit2. > http/wpt/cross-origin-resource-policy/ [ Pass ] > >+http/tests/navigation/useragent-reload.php [ Pass ] >+ > ### END OF (5) Progressions, expected successes that are expected failures in WebKit1. > ######################################## >
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 186111
: 341608