- Revision
- 292139
- Author
- [email protected]
- Date
- 2022-03-30 20:45:18 -0700 (Wed, 30 Mar 2022)
Log Message
[Cocoa] Ensure correct isAppInitiated state when creating URLRequests from URL
https://bugs.webkit.org/show_bug.cgi?id=238159
<rdar://problem/88490742>
Reviewed by Kate Cheney.
Update various load operations to ensure AppInitiated state is properly handled.
* loader/NavigationScheduler.cpp:
(WebCore::NavigationScheduler::scheduleLocationChange): The ScheduledPageBlock
load did not propagating the value of the driving document's AppInitiated state.
* loader/ThreadableLoader.cpp:
(WebCore::ThreadableLoader::create): Reflect the AppInitiated state in the load.
* page/DragController.cpp:
(WebCore::DragController::performDragOperation): A page load triggered by the user
dragging content into the view is never AppInitiated.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (292138 => 292139)
--- trunk/Source/WebCore/ChangeLog 2022-03-31 03:24:32 UTC (rev 292138)
+++ trunk/Source/WebCore/ChangeLog 2022-03-31 03:45:18 UTC (rev 292139)
@@ -1,3 +1,22 @@
+2022-03-30 Brent Fulgham <[email protected]>
+
+ [Cocoa] Ensure correct isAppInitiated state when creating URLRequests from URL
+ https://bugs.webkit.org/show_bug.cgi?id=238159
+ <rdar://problem/88490742>
+
+ Reviewed by Kate Cheney.
+
+ Update various load operations to ensure AppInitiated state is properly handled.
+
+ * loader/NavigationScheduler.cpp:
+ (WebCore::NavigationScheduler::scheduleLocationChange): The ScheduledPageBlock
+ load did not propagating the value of the driving document's AppInitiated state.
+ * loader/ThreadableLoader.cpp:
+ (WebCore::ThreadableLoader::create): Reflect the AppInitiated state in the load.
+ * page/DragController.cpp:
+ (WebCore::DragController::performDragOperation): A page load triggered by the user
+ dragging content into the view is never AppInitiated.
+
2022-03-30 Myles C. Maxfield <[email protected]>
[Cocoa] Link WebCore with WebGPU.framework 🎉
Modified: trunk/Source/WebCore/loader/NavigationScheduler.cpp (292138 => 292139)
--- trunk/Source/WebCore/loader/NavigationScheduler.cpp 2022-03-31 03:24:32 UTC (rev 292138)
+++ trunk/Source/WebCore/loader/NavigationScheduler.cpp 2022-03-31 03:45:18 UTC (rev 292139)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2022 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) 2009 Adam Barth. All rights reserved.
@@ -381,6 +381,8 @@
SubstituteData replacementData { SharedBuffer::create(), m_originDocument.url(), replacementResponse, SubstituteData::SessionHistoryVisibility::Hidden };
ResourceRequest resourceRequest { m_originDocument.url(), emptyString(), ResourceRequestCachePolicy::ReloadIgnoringCacheData };
+ if (auto* documentLoader = m_originDocument.loader())
+ resourceRequest.setIsAppInitiated(documentLoader->lastNavigationWasAppInitiated());
FrameLoadRequest frameLoadRequest { m_originDocument, m_originDocument.securityOrigin(), WTFMove(resourceRequest), { }, initiatedByMainFrame() };
frameLoadRequest.setLockHistory(lockHistory());
frameLoadRequest.setLockBackForwardList(lockBackForwardList());
Modified: trunk/Source/WebCore/loader/ThreadableLoader.cpp (292138 => 292139)
--- trunk/Source/WebCore/loader/ThreadableLoader.cpp 2022-03-31 03:24:32 UTC (rev 292138)
+++ trunk/Source/WebCore/loader/ThreadableLoader.cpp 2022-03-31 03:45:18 UTC (rev 292139)
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
* Copyright (C) 2009 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -104,15 +105,18 @@
RefPtr<ThreadableLoader> ThreadableLoader::create(ScriptExecutionContext& context, ThreadableLoaderClient& client, ResourceRequest&& request, const ThreadableLoaderOptions& options, String&& referrer, String&& taskMode)
{
- if (is<WorkerGlobalScope>(context) || (is<WorkletGlobalScope>(context) && downcast<WorkletGlobalScope>(context).workerOrWorkletThread()))
- return WorkerThreadableLoader::create(static_cast<WorkerOrWorkletGlobalScope&>(context), client, WTFMove(taskMode), WTFMove(request), options, WTFMove(referrer));
-
Document* document = nullptr;
if (is<WorkletGlobalScope>(context))
document = downcast<WorkletGlobalScope>(context).responsibleDocument();
- else
+ else if (is<Document>(context))
document = &downcast<Document>(context);
+ if (auto* documentLoader = document ? document->loader() : nullptr)
+ request.setIsAppInitiated(documentLoader->lastNavigationWasAppInitiated());
+
+ if (is<WorkerGlobalScope>(context) || (is<WorkletGlobalScope>(context) && downcast<WorkletGlobalScope>(context).workerOrWorkletThread()))
+ return WorkerThreadableLoader::create(static_cast<WorkerOrWorkletGlobalScope&>(context), client, WTFMove(taskMode), WTFMove(request), options, WTFMove(referrer));
+
return DocumentThreadableLoader::create(*document, client, WTFMove(request), options, WTFMove(referrer));
}
Modified: trunk/Source/WebCore/page/DragController.cpp (292138 => 292139)
--- trunk/Source/WebCore/page/DragController.cpp 2022-03-31 03:24:32 UTC (rev 292138)
+++ trunk/Source/WebCore/page/DragController.cpp 2022-03-31 03:45:18 UTC (rev 292139)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -294,7 +294,9 @@
return false;
client().willPerformDragDestinationAction(DragDestinationAction::Load, dragData);
- FrameLoadRequest frameLoadRequest { m_page.mainFrame(), ResourceRequest { urlString } };
+ ResourceRequest resourceRequest { urlString };
+ resourceRequest.setIsAppInitiated(false);
+ FrameLoadRequest frameLoadRequest { m_page.mainFrame(), resourceRequest };
frameLoadRequest.setShouldOpenExternalURLsPolicy(shouldOpenExternalURLsPolicy);
frameLoadRequest.setIsRequestFromClientOrUserInput();
m_page.mainFrame().loader().load(WTFMove(frameLoadRequest));