зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1645234 - Add a test for document.requestStorageAccess error messages. r=nchevobbe
Depends on D79788 Differential Revision: https://phabricator.services.mozilla.com/D80972
This commit is contained in:
Родитель
cb1b24c051
Коммит
4d4f4b4de2
|
@ -129,6 +129,7 @@ support-files =
|
|||
test-message-categories-workers.js
|
||||
test-mixedcontent-securityerrors.html
|
||||
test-navigate-to-parse-error.html
|
||||
test-nested-iframe-storageaccess-errors.html
|
||||
test-network-exceptions.html
|
||||
test-network-request.html
|
||||
test-network.html
|
||||
|
@ -146,6 +147,7 @@ support-files =
|
|||
test-sourcemap.min.js
|
||||
test-sourcemap.min.js.map
|
||||
test-stacktrace-location-debugger-link.html
|
||||
test-storageaccess-errors.html
|
||||
test-subresource-security-error.html
|
||||
test-subresource-security-error.js
|
||||
test-subresource-security-error.js^headers^
|
||||
|
@ -317,6 +319,7 @@ skip-if = (os == "linux" && fission && !ccov) || (os == "win" && fission) #Bug 1
|
|||
[browser_webconsole_promise_rejected_object.js]
|
||||
[browser_webconsole_reopen_closed_tab.js]
|
||||
[browser_webconsole_repeat_different_objects.js]
|
||||
[browser_webconsole_requestStorageAccess_errors.js]
|
||||
[browser_webconsole_reverse_search.js]
|
||||
[browser_webconsole_reverse_search_initial_value.js]
|
||||
[browser_webconsole_reverse_search_keyboard_navigation.js]
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const TEST_URI =
|
||||
"https://example.com/browser/devtools/client/webconsole/test/browser/test-storageaccess-errors.html";
|
||||
const LEARN_MORE_URI =
|
||||
"https://developer.mozilla.org/docs/Web/API/Document/requestStorageAccess" +
|
||||
DOCS_GA_PARAMS;
|
||||
|
||||
add_task(async function() {
|
||||
const hud = await openNewTabAndConsole(TEST_URI);
|
||||
|
||||
async function checkErrorMessage(text) {
|
||||
const message = await waitFor(
|
||||
() => findMessage(hud, text, ".message.error"),
|
||||
undefined,
|
||||
100
|
||||
);
|
||||
ok(true, "Error message is visible: " + text);
|
||||
|
||||
const checkLink = ({ link, where, expectedLink, expectedTab }) => {
|
||||
is(link, expectedLink, `Clicking the provided link opens ${link}`);
|
||||
is(
|
||||
where,
|
||||
expectedTab,
|
||||
`Clicking the provided link opens in expected tab`
|
||||
);
|
||||
};
|
||||
|
||||
info("Clicking on the Learn More link");
|
||||
const learnMoreLink = message.querySelector(".learn-more-link");
|
||||
const linkSimulation = await simulateLinkClick(learnMoreLink);
|
||||
checkLink({
|
||||
...linkSimulation,
|
||||
expectedLink: LEARN_MORE_URI,
|
||||
expectedTab: "tab",
|
||||
});
|
||||
}
|
||||
|
||||
const userGesture =
|
||||
"document.requestStorageAccess() may only be requested from inside a short running user-generated event handler";
|
||||
const nested =
|
||||
"document.requestStorageAccess() may not be called in a nested iframe.";
|
||||
const nullPrincipal =
|
||||
"document.requestStorageAccess() may not be called on a document with an opaque origin, such as a sandboxed iframe without allow-same-origin in its sandbox attribute.";
|
||||
const sandboxed =
|
||||
"document.requestStorageAccess() may not be called in a sandboxed iframe without allow-storage-access-by-user-activation in its sandbox attribute.";
|
||||
|
||||
await checkErrorMessage(userGesture);
|
||||
await checkErrorMessage(nullPrincipal);
|
||||
await checkErrorMessage(nested);
|
||||
await checkErrorMessage(sandboxed);
|
||||
});
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html dir="ltr" xml:lang="en-US" lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
<title>requestStorageAccess test</title>
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="https://example.org/browser/devtools/client/webconsole/test/browser/test-storageaccess-errors.html"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html dir="ltr" xml:lang="en-US" lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
<title>requestStorageAccess test</title>
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="https://example.org/browser/devtools/client/webconsole/test/browser/test-nested-iframe-storageaccess-errors.html"></iframe>
|
||||
<iframe sandbox="allow-scripts" src="https://example.com/browser/devtools/client/webconsole/test/browser/test-storageaccess-errors.html"></iframe>
|
||||
<iframe sandbox="allow-same-origin allow-scripts" src="https://example.com/browser/devtools/client/webconsole/test/browser/test-storageaccess-errors.html"></iframe>
|
||||
<script>
|
||||
'use strict';
|
||||
document.requestStorageAccess();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче