Diff
Modified: trunk/LayoutTests/ChangeLog (287347 => 287348)
--- trunk/LayoutTests/ChangeLog 2021-12-22 06:28:01 UTC (rev 287347)
+++ trunk/LayoutTests/ChangeLog 2021-12-22 06:36:13 UTC (rev 287348)
@@ -1,3 +1,22 @@
+2021-12-21 Brent Fulgham <[email protected]>
+
+ Propagate app-initiated state to new ResourceRequests
+ https://bugs.webkit.org/show_bug.cgi?id=234015
+ <rdar://problem/86128638>
+
+ Reviewed by Kate Cheney.
+
+ * http/tests/app-privacy-report/app-attribution-beacon-isappinitiated-expected.txt: Added.
+ * http/tests/app-privacy-report/app-attribution-beacon-isappinitiated.html: Added.
+ * http/tests/app-privacy-report/app-attribution-beacon-isnotappinitiated-expected.txt: Added.
+ * http/tests/app-privacy-report/app-attribution-beacon-isnotappinitiated.html: Added.
+ * http/tests/app-privacy-report/new-window-isappinitiated.html: Added.
+ * http/tests/app-privacy-report/new-window-isappinitiated-expected.txt: Added.
+ * http/tests/app-privacy-report/new-window-isnotappinitiated.html: Added.
+ * http/tests/app-privacy-report/new-window-isnotappinitiated-expected.txt: Added.
+ * http/tests/app-privacy-report/resources/new-window-isappinitiated-win.html: Added.
+ * http/tests/app-privacy-report/resources/new-window-isnotappinitiated-win.html: Added.
+
2021-12-21 Simon Fraser <[email protected]>
Fuzzy pixel data need to be computed in terms of CSS pixels
Added: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-beacon-isappinitiated-expected.txt (0 => 287348)
--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-beacon-isappinitiated-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-beacon-isappinitiated-expected.txt 2021-12-22 06:36:13 UTC (rev 287348)
@@ -0,0 +1,20 @@
+Ensure beacons are attributed correctly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS navigator.sendBeacon("../blink/sendbeacon/resources/save-beacon.py?name=cookie", "Blip"); is true
+PASS Beacon sent successfully
+PASS Content-Type: text/plain;charset=UTF-8
+PASS Cookie: hello=world
+PASS Origin: http://127.0.0.1:8000
+PASS Referer: http://127.0.0.1:8000/app-privacy-report/app-attribution-beacon-isappinitiated.html
+PASS Request-Method: POST
+PASS Length: 4
+PASS Body: Blip
+PASS
+PASS Successfully loaded only app-initiated beacon requests
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-beacon-isappinitiated.html (0 => 287348)
--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-beacon-isappinitiated.html (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-beacon-isappinitiated.html 2021-12-22 06:36:13 UTC (rev 287348)
@@ -0,0 +1,68 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=true ] -->
+<html>
+<head>
+ <script src=""
+</head>
+<body _onload_="runTest()">
+<script>
+description('Ensure beacons are attributed correctly.');
+
+window.jsTestIsAsync = true;
+
+function askForAttribution() {
+ var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
+ var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
+
+ if (didLoadNonAppInitiatedRequest) {
+ testFailed("Did load non-app initiated request");
+ finishJSTest();
+ return;
+ }
+
+ if (!didLoadAppInitiatedRequest) {
+ testFailed("Did not load app initiated request");
+ finishJSTest();
+ return;
+ }
+
+ testPassed("Successfully loaded only app-initiated beacon requests");
+
+ finishJSTest();
+}
+
+function runTest()
+{
+ try {
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "../cookies/resources/setCookies.cgi", false);
+ xhr.setRequestHeader("SET-COOKIE", "hello=world;path=/");
+ xhr.send(null);
+ if (xhr.status != 200) {
+ testFailed("cookie not set");
+ finishJSTest();
+ }
+ } catch (e) {
+ testFailed("cookie not set");
+ finishJSTest();
+ }
+
+ shouldBeTrue('navigator.sendBeacon("../blink/sendbeacon/resources/save-beacon.py?name=cookie", "Blip");');
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "../blink/sendbeacon/resources/check-beacon.py?name=cookie");
+ xhr._onload_ = function () {
+ var lines = xhr.responseText.split("\n");
+ for (var i in lines)
+ testPassed(lines[i]);
+ askForAttribution();
+ };
+ xhr._onerror_ = function () {
+ testFailed("Unable to fetch beacon status");
+ finishJSTest();
+ };
+
+ xhr.send();
+}
+</script>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-beacon-isnotappinitiated-expected.txt (0 => 287348)
--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-beacon-isnotappinitiated-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-beacon-isnotappinitiated-expected.txt 2021-12-22 06:36:13 UTC (rev 287348)
@@ -0,0 +1,20 @@
+Ensure beacons are attributed correctly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS navigator.sendBeacon("../blink/sendbeacon/resources/save-beacon.py?name=cookie", "Blip"); is true
+PASS Beacon sent successfully
+PASS Content-Type: text/plain;charset=UTF-8
+PASS Cookie: hello=world
+PASS Origin: http://127.0.0.1:8000
+PASS Referer: http://127.0.0.1:8000/app-privacy-report/app-attribution-beacon-isnotappinitiated.html
+PASS Request-Method: POST
+PASS Length: 4
+PASS Body: Blip
+PASS
+PASS Successfully loaded only non-app-initiated beacon requests
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-beacon-isnotappinitiated.html (0 => 287348)
--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-beacon-isnotappinitiated.html (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-beacon-isnotappinitiated.html 2021-12-22 06:36:13 UTC (rev 287348)
@@ -0,0 +1,68 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=false ] -->
+<html>
+<head>
+ <script src=""
+</head>
+<body _onload_="runTest()">
+<script>
+description('Ensure beacons are attributed correctly.');
+
+window.jsTestIsAsync = true;
+
+function askForAttribution() {
+ var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
+ var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
+
+ if (!didLoadNonAppInitiatedRequest) {
+ testFailed("Did not load non-app initiated request");
+ finishJSTest();
+ return;
+ }
+
+ if (didLoadAppInitiatedRequest) {
+ testFailed("Did load app initiated request");
+ finishJSTest();
+ return;
+ }
+
+ testPassed("Successfully loaded only non-app-initiated beacon requests");
+
+ finishJSTest();
+}
+
+function runTest()
+{
+ try {
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "../cookies/resources/setCookies.cgi", false);
+ xhr.setRequestHeader("SET-COOKIE", "hello=world;path=/");
+ xhr.send(null);
+ if (xhr.status != 200) {
+ testFailed("cookie not set");
+ finishJSTest();
+ }
+ } catch (e) {
+ testFailed("cookie not set");
+ finishJSTest();
+ }
+
+ shouldBeTrue('navigator.sendBeacon("../blink/sendbeacon/resources/save-beacon.py?name=cookie", "Blip");');
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "../blink/sendbeacon/resources/check-beacon.py?name=cookie");
+ xhr._onload_ = function () {
+ var lines = xhr.responseText.split("\n");
+ for (var i in lines)
+ testPassed(lines[i]);
+ askForAttribution();
+ };
+ xhr._onerror_ = function () {
+ testFailed("Unable to fetch beacon status");
+ finishJSTest();
+ };
+
+ xhr.send();
+}
+</script>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/app-privacy-report/new-window-isappinitiated-expected.txt (0 => 287348)
--- trunk/LayoutTests/http/tests/app-privacy-report/new-window-isappinitiated-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/new-window-isappinitiated-expected.txt 2021-12-22 06:36:13 UTC (rev 287348)
@@ -0,0 +1,9 @@
+CONSOLE MESSAGE: PASS: New window should have an opener
+CONSOLE MESSAGE: PASS: New window should be able to look up opener by name
+CONSOLE MESSAGE: PASS: Successfully loaded only app-initiated window content
+Make sure that windows opened via window.open are attributed correctly
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
Added: trunk/LayoutTests/http/tests/app-privacy-report/new-window-isappinitiated.html (0 => 287348)
--- trunk/LayoutTests/http/tests/app-privacy-report/new-window-isappinitiated.html (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/new-window-isappinitiated.html 2021-12-22 06:36:13 UTC (rev 287348)
@@ -0,0 +1,18 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=true ] -->
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+<script>
+description("Make sure that windows opened via window.open are attributed correctly");
+
+window.jsTestIsAsync = true;
+
+_onload_ = function() {
+ window.name = "opener";
+ w = open("resources/new-window-isappinitiated-win.html", "");
+}
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/app-privacy-report/new-window-isnotappinitiated-expected.txt (0 => 287348)
--- trunk/LayoutTests/http/tests/app-privacy-report/new-window-isnotappinitiated-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/new-window-isnotappinitiated-expected.txt 2021-12-22 06:36:13 UTC (rev 287348)
@@ -0,0 +1,9 @@
+CONSOLE MESSAGE: PASS: New window should have an opener
+CONSOLE MESSAGE: PASS: New window should be able to look up opener by name
+CONSOLE MESSAGE: PASS: Successfully loaded only non-app-initiated window content
+Make sure that windows opened via window.open are attributed correctly
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
Added: trunk/LayoutTests/http/tests/app-privacy-report/new-window-isnotappinitiated.html (0 => 287348)
--- trunk/LayoutTests/http/tests/app-privacy-report/new-window-isnotappinitiated.html (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/new-window-isnotappinitiated.html 2021-12-22 06:36:13 UTC (rev 287348)
@@ -0,0 +1,18 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=false ] -->
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+<script>
+description("Make sure that windows opened via window.open are attributed correctly");
+
+window.jsTestIsAsync = true;
+
+_onload_ = function() {
+ window.name = "opener";
+ w = open("resources/new-window-isnotappinitiated-win.html", "");
+}
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/app-privacy-report/resources/new-window-isappinitiated-win.html (0 => 287348)
--- trunk/LayoutTests/http/tests/app-privacy-report/resources/new-window-isappinitiated-win.html (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/resources/new-window-isappinitiated-win.html 2021-12-22 06:36:13 UTC (rev 287348)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+window.jsTestIsAsync = true;
+
+function askForAttribution() {
+ var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
+ var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
+
+ if (didLoadNonAppInitiatedRequest) {
+ console.log("FAIL: Loaded a non-app initiated request");
+ finishJSTest();
+ return;
+ }
+
+ if (!didLoadAppInitiatedRequest) {
+ console.log("FAIL: Did not load app initiated request");
+ finishJSTest();
+ return;
+ }
+
+ console.log("PASS: Successfully loaded only app-initiated window content");
+
+ finishJSTest();
+}
+
+_onload_ = function() {
+ if (window.opener)
+ console.log("PASS: New window should have an opener");
+ else
+ console.log("FAIL: New window should have an opener");
+
+ openerByName = open("", "opener"); // Should return the opener.
+ if (openerByName === opener)
+ console.log("PASS: New window should be able to look up opener by name");
+ else
+ console.log("FAIL: New window should be able to look up opener by name");
+
+ askForAttribution();
+};
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/app-privacy-report/resources/new-window-isnotappinitiated-win.html (0 => 287348)
--- trunk/LayoutTests/http/tests/app-privacy-report/resources/new-window-isnotappinitiated-win.html (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/resources/new-window-isnotappinitiated-win.html 2021-12-22 06:36:13 UTC (rev 287348)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+window.jsTestIsAsync = true;
+
+function askForAttribution() {
+ var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
+ var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
+
+ if (!didLoadNonAppInitiatedRequest) {
+ console.log("FAIL: Did not load non-app initiated request");
+ finishJSTest();
+ return;
+ }
+
+ if (didLoadAppInitiatedRequest) {
+ console.log("FAIL: Did load app initiated request");
+ finishJSTest();
+ return;
+ }
+
+ console.log("PASS: Successfully loaded only non-app-initiated window content");
+
+ finishJSTest();
+}
+
+_onload_ = function() {
+ if (window.opener)
+ console.log("PASS: New window should have an opener");
+ else
+ console.log("FAIL: New window should have an opener");
+
+ openerByName = open("", "opener"); // Should return the opener.
+ if (openerByName === opener)
+ console.log("PASS: New window should be able to look up opener by name");
+ else
+ console.log("FAIL: New window should be able to look up opener by name");
+
+ askForAttribution();
+};
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (287347 => 287348)
--- trunk/Source/WebCore/ChangeLog 2021-12-22 06:28:01 UTC (rev 287347)
+++ trunk/Source/WebCore/ChangeLog 2021-12-22 06:36:13 UTC (rev 287348)
@@ -1,3 +1,40 @@
+2021-12-21 Brent Fulgham <[email protected]>
+
+ Propagate app-initiated state to new ResourceRequests
+ https://bugs.webkit.org/show_bug.cgi?id=234015
+ <rdar://problem/86128638>
+
+ Reviewed by Kate Cheney.
+
+ While reviewing logging we have found that some ResourceRequest objects
+ are missing the correct state for app-initiated loads. Typically, these
+ are cases where a new ResourceRequest is created from a URL string, losing
+ the context that came with the original load (or the context of the page
+ triggering the load).
+
+ This patch corrects a number of such cases.
+
+ Tests: http/tests/app-privacy-report/app-attribution-beacon-isappinitiated.html
+ http/tests/app-privacy-report/app-attribution-beacon-isnotappinitiated.html
+ http/tests/app-privacy-report/new-window-isappinitiated.html
+ http/tests/app-privacy-report/new-window-isnotappinitiated.html
+
+ * Modules/beacon/NavigatorBeacon.cpp:
+ (WebCore::NavigatorBeacon::sendBeacon):
+ * Modules/websockets/WebSocketChannel.cpp:
+ (WebCore::WebSocketChannel::connect):
+ * Modules/websockets/WebSocketHandshake.cpp:
+ (WebCore::WebSocketHandshake::WebSocketHandshake):
+ (WebCore::WebSocketHandshake::clientHandshakeRequest const):
+ * Modules/websockets/WebSocketHandshake.h:
+ * loader/CrossOriginAccessControl.cpp:
+ (WebCore::createPotentialAccessControlRequest):
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::willLoadMediaElementURL):
+ (WebCore::FrameLoader::commitProvisionalLoad):
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::createWindow):
+
2021-12-21 Brady Eidson <[email protected]>
Make Notification identifiers be a UUID string instead of a uint64_t
Modified: trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp (287347 => 287348)
--- trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp 2021-12-22 06:28:01 UTC (rev 287347)
+++ trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp 2021-12-22 06:36:13 UTC (rev 287348)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,6 +29,7 @@
#include "CachedRawResource.h"
#include "CachedResourceLoader.h"
#include "Document.h"
+#include "DocumentLoader.h"
#include "Frame.h"
#include "HTTPParsers.h"
#include "Navigator.h"
@@ -122,6 +123,8 @@
ResourceRequest request(parsedUrl);
request.setHTTPMethod("POST"_s);
request.setRequester(ResourceRequest::Requester::Beacon);
+ if (auto* documentLoader = document.loader())
+ request.setIsAppInitiated(documentLoader->lastNavigationWasAppInitiated());
ResourceLoaderOptions options;
options.credentials = FetchOptions::Credentials::Include;
Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp (287347 => 287348)
--- trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp 2021-12-22 06:28:01 UTC (rev 287347)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp 2021-12-22 06:36:13 UTC (rev 287348)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2011, 2012 Google Inc. All rights reserved.
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -35,6 +35,7 @@
#include "Blob.h"
#include "CookieJar.h"
#include "Document.h"
+#include "DocumentLoader.h"
#include "ExceptionCode.h"
#include "FileReaderLoader.h"
#include "Frame.h"
@@ -92,7 +93,12 @@
m_allowCookies = validatedURL->areCookiesAllowed;
String userAgent = m_document->userAgent(m_document->url());
String clientOrigin = m_document->securityOrigin().toString();
- m_handshake = makeUnique<WebSocketHandshake>(validatedURL->url, protocol, userAgent, clientOrigin, m_allowCookies);
+
+ bool isAppInitiated = true;
+ if (auto* documentLoader = m_document->loader())
+ isAppInitiated = documentLoader->lastNavigationWasAppInitiated();
+
+ m_handshake = makeUnique<WebSocketHandshake>(validatedURL->url, protocol, userAgent, clientOrigin, m_allowCookies, isAppInitiated);
m_handshake->reset();
m_handshake->addExtensionProcessor(m_deflateFramer.createExtensionProcessor());
if (m_progressIdentifier)
Modified: trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp (287347 => 287348)
--- trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp 2021-12-22 06:28:01 UTC (rev 287347)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp 2021-12-22 06:36:13 UTC (rev 287348)
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
* Copyright (C) Research In Motion Limited 2011. All rights reserved.
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -112,7 +112,7 @@
return base64EncodeToString(hash.data(), SHA1::hashSize);
}
-WebSocketHandshake::WebSocketHandshake(const URL& url, const String& protocol, const String& userAgent, const String& clientOrigin, bool allowCookies)
+WebSocketHandshake::WebSocketHandshake(const URL& url, const String& protocol, const String& userAgent, const String& clientOrigin, bool allowCookies, bool isAppInitiated)
: m_url(url)
, m_clientProtocol(protocol)
, m_secure(m_url.protocolIs("wss"))
@@ -120,6 +120,7 @@
, m_userAgent(userAgent)
, m_clientOrigin(clientOrigin)
, m_allowCookies(allowCookies)
+ , m_isAppInitiated(isAppInitiated)
{
m_secWebSocketKey = generateSecWebSocketKey();
m_expectedAccept = getExpectedWebSocketAccept(m_secWebSocketKey);
@@ -212,6 +213,7 @@
if (!extensions.isEmpty())
request.setHTTPHeaderField(HTTPHeaderName::SecWebSocketExtensions, extensions);
request.setHTTPUserAgent(m_userAgent);
+ request.setIsAppInitiated(m_isAppInitiated);
return request;
}
Modified: trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.h (287347 => 287348)
--- trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.h 2021-12-22 06:28:01 UTC (rev 287347)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.h 2021-12-22 06:36:13 UTC (rev 287348)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -48,7 +49,7 @@
enum Mode {
Incomplete, Normal, Failed, Connected
};
- WebSocketHandshake(const URL&, const String& protocol, const String& userAgent, const String& clientOrigin, bool allowCookies);
+ WebSocketHandshake(const URL&, const String& protocol, const String& userAgent, const String& clientOrigin, bool allowCookies, bool isAppInitiated);
~WebSocketHandshake();
const URL& url() const;
@@ -102,6 +103,7 @@
String m_userAgent;
String m_clientOrigin;
bool m_allowCookies;
+ bool m_isAppInitiated;
ResourceResponse m_serverHandshakeResponse;
Modified: trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp (287347 => 287348)
--- trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp 2021-12-22 06:28:01 UTC (rev 287347)
+++ trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp 2021-12-22 06:36:13 UTC (rev 287348)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008-2021 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -139,6 +139,9 @@
}
}
+ if (auto* documentLoader = document.loader())
+ request.setIsAppInitiated(documentLoader->lastNavigationWasAppInitiated());
+
if (crossOriginAttribute.isNull()) {
CachedResourceRequest cachedRequest { WTFMove(request), WTFMove(options) };
cachedRequest.setOrigin(document.securityOrigin());
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (287347 => 287348)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2021-12-22 06:28:01 UTC (rev 287347)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2021-12-22 06:36:13 UTC (rev 287348)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2021 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2008 Alp Toker <[email protected]>
@@ -1681,6 +1681,8 @@
ResourceRequest request(url);
request.setInspectorInitiatorNodeIdentifier(InspectorInstrumentation::identifierForNode(initiatorNode));
+ if (m_documentLoader)
+ request.setIsAppInitiated(m_documentLoader->lastNavigationWasAppInitiated());
ResourceLoaderIdentifier identifier;
ResourceError error;
@@ -2128,6 +2130,8 @@
ResourceError error;
ResourceLoaderIdentifier identifier;
ResourceRequest request(response.url());
+ if (m_documentLoader)
+ request.setIsAppInitiated(m_documentLoader->lastNavigationWasAppInitiated());
requestFromDelegate(request, identifier, error);
// FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
// However, with today's computers and networking speeds, this won't happen in practice.
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (287347 => 287348)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2021-12-22 06:28:01 UTC (rev 287347)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2021-12-22 06:36:13 UTC (rev 287348)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2021 Apple Inc. All rights reserved.
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
@@ -2514,6 +2514,9 @@
auto initiatedByMainFrame = activeFrame->isMainFrame() ? InitiatedByMainFrame::Yes : InitiatedByMainFrame::Unknown;
ResourceRequest resourceRequest { completedURL, referrer };
+ auto* openerDocumentLoader = openerFrame.document() ? openerFrame.document()->loader() : nullptr;
+ if (openerDocumentLoader)
+ resourceRequest.setIsAppInitiated(openerDocumentLoader->lastNavigationWasAppInitiated());
FrameLoadRequest frameLoadRequest { *activeDocument, activeDocument->securityOrigin(), WTFMove(resourceRequest), frameName, initiatedByMainFrame };
frameLoadRequest.setShouldOpenExternalURLsPolicy(activeDocument->shouldOpenExternalURLsPolicyToPropagate());
Modified: trunk/Source/WebKit/ChangeLog (287347 => 287348)
--- trunk/Source/WebKit/ChangeLog 2021-12-22 06:28:01 UTC (rev 287347)
+++ trunk/Source/WebKit/ChangeLog 2021-12-22 06:36:13 UTC (rev 287348)
@@ -1,3 +1,27 @@
+2021-12-21 Brent Fulgham <[email protected]>
+
+ Propagate app-initiated state to new ResourceRequests
+ https://bugs.webkit.org/show_bug.cgi?id=234015
+ <rdar://problem/86128638>
+
+ Reviewed by Kate Cheney.
+
+ While reviewing logging we have found that some ResourceRequest objects
+ are missing the correct state for app-initiated loads. Typically, these
+ are cases where a new ResourceRequest is created from a URL string, losing
+ the context that came with the original load (or the context of the page
+ triggering the load).
+
+ This patch corrects a number of such cases.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::createNewPage): Propagate app-initiated state to newly created page.
+ * NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp:
+ (WebKit::NetworkCache::SubresourceInfo::encode const): Correct missing serialization for
+ app-initiated state.
+ (WebKit::NetworkCache::SubresourceInfo::decode):
+ (WebKit::NetworkCache::SubresourceInfo::SubresourceInfo):
+
2021-12-21 Alex Christensen <[email protected]>
Fix some API tests after r287341
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp (287347 => 287348)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp 2021-12-22 06:28:01 UTC (rev 287347)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp 2021-12-22 06:36:13 UTC (rev 287348)
@@ -47,6 +47,7 @@
return;
encoder << m_isSameSite;
+ encoder << m_isAppInitiated;
encoder << m_firstPartyForCookies;
encoder << m_requestHeaders;
encoder << m_priority;
@@ -89,6 +90,12 @@
return std::nullopt;
info.m_isSameSite = WTFMove(*isSameSite);
+ std::optional<bool> isAppInitiated;
+ decoder >> isAppInitiated;
+ if (!isAppInitiated)
+ return std::nullopt;
+ info.m_isAppInitiated = WTFMove(*isAppInitiated);
+
std::optional<URL> firstPartyForCookies;
decoder >> firstPartyForCookies;
if (!firstPartyForCookies)
@@ -158,6 +165,7 @@
, m_firstSeen(previousInfo ? previousInfo->firstSeen() : m_lastSeen)
, m_isTransient(!previousInfo)
, m_isSameSite(request.isSameSite())
+ , m_isAppInitiated(request.isAppInitiated())
, m_firstPartyForCookies(request.firstPartyForCookies())
, m_requestHeaders(request.httpHeaderFields())
, m_priority(request.priority())
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (287347 => 287348)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-12-22 06:28:01 UTC (rev 287347)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-12-22 06:36:13 UTC (rev 287348)
@@ -5844,7 +5844,12 @@
auto* originatingPage = m_process->webPage(originatingPageID);
auto originatingFrameInfo = API::FrameInfo::create(WTFMove(originatingFrameInfoData), originatingPage);
auto mainFrameURL = m_mainFrame ? m_mainFrame->url() : URL();
- auto completionHandler = [this, protectedThis = Ref { *this }, mainFrameURL, request, reply = WTFMove(reply), privateClickMeasurement = navigationActionData.privateClickMeasurement] (RefPtr<WebPageProxy> newPage) mutable {
+
+ std::optional<bool> openerAppInitiatedState;
+ if (originatingPage)
+ openerAppInitiatedState = originatingPage->lastNavigationWasAppInitiated();
+
+ auto completionHandler = [this, protectedThis = Ref { *this }, mainFrameURL, request, reply = WTFMove(reply), privateClickMeasurement = navigationActionData.privateClickMeasurement, openerAppInitiatedState = WTFMove(openerAppInitiatedState)] (RefPtr<WebPageProxy> newPage) mutable {
if (!newPage) {
reply(std::nullopt, std::nullopt);
return;
@@ -5852,6 +5857,9 @@
newPage->setOpenedByDOM();
+ if (openerAppInitiatedState)
+ newPage->m_lastNavigationWasAppInitiated = *openerAppInitiatedState;
+
reply(newPage->webPageID(), newPage->creationParameters(m_process, *newPage->drawingArea()));
newPage->m_shouldSuppressAppLinksInNextNavigationPolicyDecision = mainFrameURL.host() == request.url().host();