-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make requestStorageAccess return NoModificationAllowedError until fra…
…me is reloaded https://bugs.webkit.org/show_bug.cgi?id=269108 rdar://122676929 Reviewed by Alex Christensen. Add a feature flag to make requestStorageAccess return NoModificationAllowedError on granted request until frame is reloaded, to faciliate testing behavior change on requestStorageAccess when site isolation is enabled. Test: http/tests/storageAccess/request-throw-exception-on-grant-until-reload.html * LayoutTests/http/tests/storageAccess/request-throw-exception-on-grant-until-reload-expected.txt: Added. * LayoutTests/http/tests/storageAccess/request-throw-exception-on-grant-until-reload.html: Added. * LayoutTests/http/tests/storageAccess/resources/request-throw-exception-on-grant-until-reload-iframe.html: Added. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/dom/DocumentStorageAccess.cpp: (WebCore::DocumentStorageAccess::requestStorageAccess): (WebCore::DocumentStorageAccess::requestStorageAccessQuirk): * Source/WebCore/dom/DocumentStorageAccess.h: * Source/WebCore/page/Quirks.h: * Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h: * Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess): (WebKit::WebResourceLoadStatisticsStore::grantStorageAccess): (WebKit::WebResourceLoadStatisticsStore::grantStorageAccessEphemeral): (WebKit::WebResourceLoadStatisticsStore::grantStorageAccessInStorageSession): (WebKit::WebResourceLoadStatisticsStore::recordFrameLoadForStorageAccess): (WebKit::WebResourceLoadStatisticsStore::clearFrameLoadRecordsForStorageAccess): (WebKit::WebResourceLoadStatisticsStore::storageAccessWasGrantedValueForFrame): * Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: * Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp: (WebKit::NetworkConnectionToWebProcess::scheduleResourceLoad): (WebKit::NetworkConnectionToWebProcess::clearFrameLoadRecordsForStorageAccess): * Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h: * Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in: * Source/WebKit/NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::removeWebPageNetworkParameters): * Source/WebKit/NetworkProcess/NetworkProcess.h: * Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp: (WebKit::NetworkResourceLoadParameters::NetworkResourceLoadParameters): * Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h: * Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.serialization.in: * Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in: * Source/WebKit/UIProcess/Network/NetworkProcessProxy.h: * Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp: (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess): * Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h: * Source/WebKit/WebProcess/WebProcess.cpp: (WebKit::WebProcess::removeWebFrame): * Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: * Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp: (WTR::TestRunner::setRequestStorageAccessThrowsExceptionUntilReload): * Tools/WebKitTestRunner/InjectedBundle/TestRunner.h: * Tools/WebKitTestRunner/TestController.cpp: (WTR::TestController::setRequestStorageAccessThrowsExceptionUntilReload): * Tools/WebKitTestRunner/TestController.h: * Tools/WebKitTestRunner/TestInvocation.cpp: (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): Canonical link: https://commits.webkit.org/274636@main
- Loading branch information
Showing
29 changed files
with
290 additions
and
25 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...Tests/http/tests/storageAccess/request-throw-exception-on-grant-until-reload-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Tests that requestStorageAccess throws exception on cross-site iframe until iframe is reloaded | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS requestStorageAccess result: NoModificationAllowedError | ||
PASS requestStorageAccess result: Granted | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
81 changes: 81 additions & 0 deletions
81
LayoutTests/http/tests/storageAccess/request-throw-exception-on-grant-until-reload.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
<script src="/js-test-resources/ui-helper.js"></script> | ||
<script src="/resourceLoadStatistics/resources/util.js"></script> | ||
<script> | ||
description("Tests that requestStorageAccess throws exception on cross-site iframe until iframe is reloaded"); | ||
jsTestIsAsync = true; | ||
testEnded = false; | ||
testStarted = false; | ||
|
||
function endTest() { | ||
if (testEnded) | ||
return; | ||
|
||
testEnded = true; | ||
testRunner.setRequestStorageAccessThrowsExceptionUntilReload(false); | ||
setEnableFeature(false, finishJSTest); | ||
} | ||
|
||
function receiveMessage(event) { | ||
if (event.origin !== "http://localhost:8000") { | ||
testFailed("Unexpected origin: " + event.origin); | ||
endTest(); | ||
return; | ||
} | ||
|
||
if (event.data == "NoModificationAllowedError") { | ||
testPassed("requestStorageAccess result: " + event.data); | ||
return; | ||
} | ||
|
||
if (event.data == "Done") { | ||
testPassed("requestStorageAccess result: Granted"); | ||
endTest(); | ||
return; | ||
} | ||
|
||
testFailed("Unexpected message: " + event.data); | ||
endTest(); | ||
} | ||
|
||
function activateElement(elementId) { | ||
var element = document.getElementById(elementId); | ||
var centerX = element.offsetLeft + element.offsetWidth / 2; | ||
var centerY = element.offsetTop + element.offsetHeight / 2; | ||
UIHelper.activateAt(centerX, centerY).then(() => { | ||
if (window.eventSender) | ||
eventSender.keyDown("escape"); | ||
else { | ||
testFailed("eventSender is missing"); | ||
endTest(); | ||
} | ||
}).catch(() => { | ||
testFailed("activateAt failed"); | ||
endTest(); | ||
}); | ||
} | ||
|
||
function frameLoaded() { | ||
if (!testStarted) { | ||
setEnableFeature(true, function() { | ||
activateElement("TheIframeThatRequestsStorageAccess"); | ||
}); | ||
return; | ||
} | ||
|
||
testStarted = true; | ||
activateElement("TheIframeThatRequestsStorageAccess"); | ||
} | ||
|
||
window.addEventListener("message", receiveMessage, false); | ||
if (window.testRunner) | ||
testRunner.setRequestStorageAccessThrowsExceptionUntilReload(true); | ||
</script> | ||
</head> | ||
<body> | ||
<iframe sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals" onload="frameLoaded()" id="TheIframeThatRequestsStorageAccess" src="http://localhost:8000/storageAccess/resources/request-throw-exception-on-grant-until-reload-iframe.html"></iframe> | ||
</body> | ||
</html> |
25 changes: 25 additions & 0 deletions
25
...p/tests/storageAccess/resources/request-throw-exception-on-grant-until-reload-iframe.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<html> | ||
<head> | ||
<script> | ||
function messageToTop(message) { | ||
top.postMessage(message, "http://127.0.0.1:8000"); | ||
} | ||
|
||
function performStorageAccessRequest() { | ||
document.requestStorageAccess().then(() => { | ||
messageToTop("Done"); | ||
}).catch((error) => { | ||
if (!error) { | ||
messageToTop("None"); | ||
return; | ||
} | ||
|
||
messageToTop(error.name); | ||
if (!window.location.hash && error.name == "NoModificationAllowedError") | ||
location.reload(); | ||
}); | ||
} | ||
</script> | ||
</head> | ||
<body onclick="performStorageAccessRequest()"> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.