зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1693453 [wpt PR 27671] - Add test to check the unavailability of storages in urn uuid iframes, a=testonly
Automatic update from web-platform-tests Add test to check the unavailability of storages in urn uuid iframes Bug: 1082020 Change-Id: I2043a4db68fb66c3ae7d24990e10cf85aadb2101 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2702998 Commit-Queue: Tsuyoshi Horo <horo@chromium.org> Reviewed-by: Kunihiko Sakamoto <ksakamoto@chromium.org> Cr-Commit-Position: refs/heads/master@{#855126} -- wpt-commits: 650f204fcb86070a61ccfd4fc63b6c3e8c0c142c wpt-pr: 27671
This commit is contained in:
Родитель
5adfeeae50
Коммит
729332a670
|
@ -35,7 +35,7 @@
|
|||
}
|
||||
],
|
||||
"content": {
|
||||
"text": "<script> window.parent.postMessage('subframe loaded from WBN: location = ' + location.href, '*'); </script>"
|
||||
"text": "<script>\nwindow.addEventListener('message', (e) =>{e.source.postMessage(eval(e.data), e.origin);});\n</script>"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Двоичные данные
testing/web-platform/tests/web-bundle/resources/wbn/urn-uuid.wbn
Двоичные данные
testing/web-platform/tests/web-bundle/resources/wbn/urn-uuid.wbn
Двоичный файл не отображается.
|
@ -9,27 +9,98 @@
|
|||
<body>
|
||||
<script>
|
||||
|
||||
promise_test(async () => {
|
||||
const frame_url = 'urn:uuid:429fcc4e-0696-4bad-b099-ee9175f023ae';
|
||||
|
||||
urn_uuid_iframe_test(
|
||||
'location.href',
|
||||
frame_url,
|
||||
'location.href in urn uuid iframe.');
|
||||
|
||||
urn_uuid_iframe_test(
|
||||
'(' + (() => {
|
||||
try {
|
||||
let result = window.localStorage;
|
||||
return 'no error';
|
||||
} catch (e) {
|
||||
return e.name;
|
||||
}
|
||||
}).toString() + ')()',
|
||||
'SecurityError',
|
||||
'Accesing window.localStorage should throw a SecurityError.');
|
||||
|
||||
urn_uuid_iframe_test(
|
||||
'(' + (() => {
|
||||
try {
|
||||
let result = window.sessionStorage;
|
||||
return 'no error';
|
||||
} catch (e) {
|
||||
return e.name;
|
||||
}
|
||||
}).toString() + ')()',
|
||||
'SecurityError',
|
||||
'Accesing window.sessionStorage should throw a SecurityError.');
|
||||
|
||||
urn_uuid_iframe_test(
|
||||
'(' + (() => {
|
||||
try {
|
||||
let result = document.cookie;
|
||||
return 'no error';
|
||||
} catch (e) {
|
||||
return e.name;
|
||||
}
|
||||
}).toString() + ')()',
|
||||
'SecurityError',
|
||||
'Accesing document.cookie should throw a SecurityError.');
|
||||
|
||||
urn_uuid_iframe_test(
|
||||
'(' + (() => {
|
||||
try {
|
||||
let request = window.indexedDB.open("db");
|
||||
return 'no error';
|
||||
} catch (e) {
|
||||
return e.name;
|
||||
}
|
||||
}).toString() + ')()',
|
||||
'SecurityError',
|
||||
'Opening an indexedDB should throw a SecurityError.');
|
||||
|
||||
urn_uuid_iframe_test(
|
||||
'window.caches === undefined',
|
||||
true,
|
||||
'window.caches should be undefined.');
|
||||
|
||||
function urn_uuid_iframe_test(code, expected, name) {
|
||||
promise_test(async () => {
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'webbundle';
|
||||
link.href = '../resources/wbn/urn-uuid.wbn';
|
||||
link.resources = frame_url;
|
||||
document.body.appendChild(link);
|
||||
const message_promisse = new Promise((resolve) => {
|
||||
window.addEventListener('message', (e) => {
|
||||
resolve(e.data);
|
||||
});
|
||||
});
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.src = frame_url;
|
||||
const load_promise = new Promise((resolve) => {
|
||||
iframe.addEventListener('load', resolve);
|
||||
});
|
||||
document.body.appendChild(iframe);
|
||||
await load_promise;
|
||||
assert_equals(
|
||||
await message_promisse,
|
||||
'subframe loaded from WBN: location = ' + frame_url);
|
||||
await evalInIframe(iframe, code),
|
||||
expected);
|
||||
document.body.removeChild(link);
|
||||
document.body.removeChild(iframe);
|
||||
}, "Subframe load from Web Bundle");
|
||||
}, name);
|
||||
}
|
||||
|
||||
async function evalInIframe(iframe, code) {
|
||||
const message_promise = new Promise((resolve) => {
|
||||
const listener = (e) => {
|
||||
window.removeEventListener('message', listener);
|
||||
resolve(e.data);
|
||||
}
|
||||
window.addEventListener('message', listener);
|
||||
});
|
||||
iframe.contentWindow.postMessage(code,'*');
|
||||
return message_promise;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
|
Загрузка…
Ссылка в новой задаче