mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update web-platform-tests to revision be5419e845d39089ba6dc338c1bd0fa279108317
This commit is contained in:
parent
aa199307c8
commit
2b6f573eb5
3440 changed files with 109438 additions and 41750 deletions
|
@ -0,0 +1,4 @@
|
|||
t.step(() => {
|
||||
assert_equals(script_run_status, "deferred", "the script run status");
|
||||
});
|
||||
t.done();
|
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Choice of parse errors</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Parse errors in different files should be reported " +
|
||||
"depending on different roots");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_equals(log.length, 4);
|
||||
|
||||
// Two different parse errors from different module scripts
|
||||
// should be reported for each <script> element.
|
||||
assert_equals(log[0].constructor, SyntaxError);
|
||||
assert_equals(log[1], 1);
|
||||
|
||||
assert_equals(log[2].constructor, SyntaxError);
|
||||
assert_equals(log[3], 2);
|
||||
|
||||
assert_not_equals(log[0], log[2],
|
||||
'two different parse errors should be reported');
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="./choice-of-error-1a.js"
|
||||
onerror="unreachable()" onload="log.push(1)"></script>
|
||||
<script type="module" src="./choice-of-error-1b.js"
|
||||
onerror="unreachable()" onload="log.push(2)"></script>
|
|
@ -0,0 +1,2 @@
|
|||
import './choice-of-error-1b.js';
|
||||
import './syntaxerror.js?1c';
|
|
@ -0,0 +1,2 @@
|
|||
import './choice-of-error-1a.js';
|
||||
import './syntaxerror.js?1d';
|
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Choice of instantiation errors</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Instantiation errors in different files should be reported " +
|
||||
"depending on different roots");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_equals(log.length, 4);
|
||||
|
||||
// Two different instantiation errors from different module scripts
|
||||
// should be reported for each <script> element.
|
||||
assert_equals(log[0].constructor, SyntaxError);
|
||||
assert_equals(log[1], 1);
|
||||
|
||||
assert_equals(log[2].constructor, SyntaxError);
|
||||
assert_equals(log[3], 2);
|
||||
|
||||
assert_not_equals(log[0], log[2],
|
||||
'two different instantiation errors should be reported');
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="./choice-of-error-2a.js"
|
||||
onerror="unreachable()" onload="log.push(1)"></script>
|
||||
<script type="module" src="./choice-of-error-2b.js"
|
||||
onerror="unreachable()" onload="log.push(2)"></script>
|
|
@ -0,0 +1,2 @@
|
|||
import './choice-of-error-2b.js';
|
||||
import './instantiation-error-1.js?2c';
|
|
@ -0,0 +1,2 @@
|
|||
import './choice-of-error-2a.js';
|
||||
import './instantiation-error-1.js?2d';
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Choice of evaluation errors</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Evaluation errors are cached in intermediate module scripts");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_equals(log.length, 5);
|
||||
|
||||
// Evaluation errors, unlike parse/instantiation errors, are remembered
|
||||
// and cached in module scripts between the root and the script that
|
||||
// caused an evaluation error, and thus the same evaluation error
|
||||
// is reported for both <script> elements.
|
||||
assert_equals(log[0], "throw2");
|
||||
assert_true(log[1].bar);
|
||||
assert_equals(log[2], 1);
|
||||
|
||||
assert_true(log[3].bar);
|
||||
assert_equals(log[4], 2);
|
||||
|
||||
assert_equals(log[1], log[3], 'evaluation errors must be the same');
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="./choice-of-error-3a.js"
|
||||
onerror="unreachable()" onload="log.push(1)"></script>
|
||||
<script type="module" src="./choice-of-error-3b.js"
|
||||
onerror="unreachable()" onload="log.push(2)"></script>
|
|
@ -0,0 +1,2 @@
|
|||
import './choice-of-error-3b.js';
|
||||
import './throw.js?3c';
|
|
@ -0,0 +1,2 @@
|
|||
import './choice-of-error-3a.js';
|
||||
import './throw2.js?3d';
|
|
@ -9,7 +9,7 @@ const cases = [
|
|||
["parse error", "../syntaxerror.js", new SyntaxError],
|
||||
["bad module specifier", "does-not-start-with-dot.js", new TypeError, { differentErrorObjects: true }],
|
||||
["bad module specifier in a dependency", "../bad-module-specifier.js", new TypeError],
|
||||
["instantiation error", "../instantiation-error-1.js", new SyntaxError],
|
||||
["instantiation error", "../instantiation-error-1.js", new SyntaxError, { differentErrorObjects: true }],
|
||||
["evaluation error", "../throw-error.js", new Error]
|
||||
];
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Function(`import('../../imports-a.js?label=' + window.label).then(window.continueTest, window.errorTest)`)();
|
|
@ -0,0 +1 @@
|
|||
eval(`import('../../imports-a.js?label=' + window.label).then(window.continueTest, window.errorTest)`);
|
|
@ -0,0 +1,2 @@
|
|||
window.dummyDiv.setAttribute("onclick", `import('../../imports-a.js?label=' + window.label).then(window.continueTest, window.errorTest)`);
|
||||
window.dummyDiv.click(); // different from **on**click()
|
|
@ -0,0 +1,2 @@
|
|||
window.dummyDiv.setAttribute("onclick", `import('../../imports-a.js?label=' + window.label).then(window.continueTest, window.errorTest)`);
|
||||
window.dummyDiv.onclick();
|
|
@ -0,0 +1 @@
|
|||
setTimeout(`import('../../imports-a.js?label=' + window.label).then(window.continueTest, window.errorTest)`, 0);
|
|
@ -0,0 +1,52 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>import() inside compiled strings uses the script base URL inside a classic script that is loaded from a file</title>
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<div id="dummy"></div>
|
||||
|
||||
<script>
|
||||
function load(scriptSrc) {
|
||||
const el = document.createElement("script");
|
||||
el.src = scriptSrc;
|
||||
document.body.appendChild(el);
|
||||
}
|
||||
|
||||
function createTestPromise() {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.dummyDiv.removeAttribute("onclick");
|
||||
delete window.evaluated_imports_a;
|
||||
delete window.label;
|
||||
|
||||
window.continueTest = resolve;
|
||||
window.errorTest = reject;
|
||||
});
|
||||
}
|
||||
|
||||
window.dummyDiv = document.querySelector("#dummy");
|
||||
|
||||
const evaluators = [
|
||||
"setTimeout",
|
||||
"eval",
|
||||
"Function",
|
||||
"reflected-inline-event-handlers",
|
||||
"inline-event-handlers-UA-code"
|
||||
];
|
||||
|
||||
for (const label of evaluators) {
|
||||
promise_test(() => {
|
||||
const promise = createTestPromise();
|
||||
|
||||
window.label = label;
|
||||
load(`scripts/${label}.js`);
|
||||
|
||||
return promise.then(module => {
|
||||
assert_true(window.evaluated_imports_a, "The module must have been evaluated");
|
||||
assert_equals(module.A.from, "imports-a.js", "The module namespace object must be correct");
|
||||
});
|
||||
}, label + " should successfully import");
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,53 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>import() inside compiled strings uses the script base URL inside a module script that is loaded from a file</title>
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<div id="dummy"></div>
|
||||
|
||||
<script type="module">
|
||||
function load(scriptSrc) {
|
||||
const el = document.createElement("script");
|
||||
el.type = "module";
|
||||
el.src = scriptSrc;
|
||||
document.body.appendChild(el);
|
||||
}
|
||||
|
||||
function createTestPromise() {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.dummyDiv.removeAttribute("onclick");
|
||||
delete window.evaluated_imports_a;
|
||||
delete window.label;
|
||||
|
||||
window.continueTest = resolve;
|
||||
window.errorTest = reject;
|
||||
});
|
||||
}
|
||||
|
||||
window.dummyDiv = document.querySelector("#dummy");
|
||||
|
||||
const evaluators = [
|
||||
"setTimeout",
|
||||
"eval",
|
||||
"Function",
|
||||
"reflected-inline-event-handlers",
|
||||
"inline-event-handlers-UA-code"
|
||||
];
|
||||
|
||||
for (const label of evaluators) {
|
||||
promise_test(() => {
|
||||
const promise = createTestPromise();
|
||||
|
||||
window.label = label;
|
||||
load(`scripts/${label}.js`);
|
||||
|
||||
return promise.then(module => {
|
||||
assert_true(window.evaluated_imports_a, "The module must have been evaluated");
|
||||
assert_equals(module.A.from, "imports-a.js", "The module namespace object must be correct");
|
||||
});
|
||||
}, label + " should successfully import");
|
||||
};
|
||||
</script>
|
|
@ -1,6 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>import() inside compiled strings uses the document base URL inside a classic script</title>
|
||||
<title>import() inside compiled strings uses the script base URL (= document base URL) inside an inline classic script</title>
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<base href="..">
|
||||
|
@ -21,8 +21,8 @@ function createTestPromise() {
|
|||
const dummyDiv = document.querySelector("#dummy");
|
||||
|
||||
const evaluators = {
|
||||
eval,
|
||||
setTimeout,
|
||||
eval,
|
||||
"the Function constructor"(x) {
|
||||
Function(x)();
|
||||
},
|
|
@ -1,6 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>import() inside compiled strings uses the document base URL inside a module script</title>
|
||||
<title>import() inside compiled strings uses the script base URL (= document base URL) inside an inline module script</title>
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<base href="..">
|
||||
|
@ -21,8 +21,8 @@ function createTestPromise() {
|
|||
const dummyDiv = document.querySelector("#dummy");
|
||||
|
||||
const evaluators = {
|
||||
eval,
|
||||
setTimeout,
|
||||
eval,
|
||||
"the Function constructor"(x) {
|
||||
Function(x)();
|
||||
},
|
|
@ -0,0 +1,52 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>import() doesn't have any integrity metadata when initiated by compiled strings inside a classic script</title>
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
<meta http-equiv="Content-Security-Policy" content="require-sri-for script">
|
||||
|
||||
<script src="/resources/testharness.js" integrity="sha384-4Nybydhnr3tOpv1yrTkDxu3RFpnxWAxlU5kGn7c8ebKvh1iUdfVMjqP6jf0dacrV"></script>
|
||||
<script src="/resources/testharnessreport.js" integrity="sha384-GOnHxuyo+nnsFAe4enY+RAl4/+w5NPMJPCQiDroTjxtR7ndRz7Uan8vNbM2qWKmU"></script>
|
||||
|
||||
<div id="dummy"></div>
|
||||
|
||||
<script>
|
||||
function createTestPromise() {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.continueTest = resolve;
|
||||
window.errorTest = reject;
|
||||
});
|
||||
}
|
||||
|
||||
const dummyDiv = document.querySelector("#dummy");
|
||||
|
||||
const evaluators = {
|
||||
eval,
|
||||
setTimeout,
|
||||
"the Function constructor"(x) {
|
||||
Function(x)();
|
||||
},
|
||||
"reflected inline event handlers"(x) {
|
||||
dummyDiv.setAttribute("onclick", x);
|
||||
dummyDiv.onclick();
|
||||
},
|
||||
"inline event handlers triggered via UA code"(x) {
|
||||
dummyDiv.setAttribute("onclick", x);
|
||||
dummyDiv.click(); // different from .**on**click()
|
||||
}
|
||||
};
|
||||
|
||||
for (const [label, evaluator] of Object.entries(evaluators)) {
|
||||
promise_test(t => {
|
||||
t.add_cleanup(() => {
|
||||
dummyDiv.removeAttribute("onclick");
|
||||
delete window.evaluated_imports_a;
|
||||
});
|
||||
|
||||
const promise = createTestPromise();
|
||||
|
||||
evaluator(`import('../imports-a.js?label=${label}').then(window.continueTest, window.errorTest);`);
|
||||
|
||||
return promise_rejects(t, new TypeError(), promise);
|
||||
}, label + " should fail to import");
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,52 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>import() doesn't have any integrity metadata when initiated by compiled strings inside a module script</title>
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
<meta http-equiv="Content-Security-Policy" content="require-sri-for script">
|
||||
|
||||
<script src="/resources/testharness.js" integrity="sha384-4Nybydhnr3tOpv1yrTkDxu3RFpnxWAxlU5kGn7c8ebKvh1iUdfVMjqP6jf0dacrV"></script>
|
||||
<script src="/resources/testharnessreport.js" integrity="sha384-GOnHxuyo+nnsFAe4enY+RAl4/+w5NPMJPCQiDroTjxtR7ndRz7Uan8vNbM2qWKmU"></script>
|
||||
|
||||
<div id="dummy"></div>
|
||||
|
||||
<script type="module">
|
||||
function createTestPromise() {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.continueTest = resolve;
|
||||
window.errorTest = reject;
|
||||
});
|
||||
}
|
||||
|
||||
const dummyDiv = document.querySelector("#dummy");
|
||||
|
||||
const evaluators = {
|
||||
eval,
|
||||
setTimeout,
|
||||
"the Function constructor"(x) {
|
||||
Function(x)();
|
||||
},
|
||||
"reflected inline event handlers"(x) {
|
||||
dummyDiv.setAttribute("onclick", x);
|
||||
dummyDiv.onclick();
|
||||
},
|
||||
"inline event handlers triggered via UA code"(x) {
|
||||
dummyDiv.setAttribute("onclick", x);
|
||||
dummyDiv.click(); // different from .**on**click()
|
||||
}
|
||||
};
|
||||
|
||||
for (const [label, evaluator] of Object.entries(evaluators)) {
|
||||
promise_test(t => {
|
||||
t.add_cleanup(() => {
|
||||
dummyDiv.removeAttribute("onclick");
|
||||
delete window.evaluated_imports_a;
|
||||
});
|
||||
|
||||
const promise = createTestPromise();
|
||||
|
||||
evaluator(`import('../imports-a.js?label=${label}').then(window.continueTest, window.errorTest);`);
|
||||
|
||||
return promise_rejects(t, new TypeError(), promise);
|
||||
}, label + " should fail to import");
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,103 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>import() inside compiled strings uses the appropriate nonce inside a classic script</title>
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<meta http-equiv="content-security-policy" content="script-src 'nonce-correct' 'unsafe-eval' 'unsafe-hashed-attributes' 'sha256-cAMzxBL19bKt4KwKGbxy/ZOFIIjH5AmRjlVbsD5pvNw=' 'sha256-3VjoJYNK/9HJMS8rrZHlqSZgUssDY+GPyc7AU8lNM3k='">
|
||||
|
||||
<script nonce="correct" src="/resources/testharness.js"></script>
|
||||
<script nonce="correct" src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<div id="dummy"></div>
|
||||
|
||||
<script nonce="correct">
|
||||
"use strict";
|
||||
const dummyDiv = document.querySelector("#dummy");
|
||||
|
||||
function createTestPromise(t) {
|
||||
t.add_cleanup(() => {
|
||||
delete window.evaluated_imports_a;
|
||||
delete window.unreached;
|
||||
delete window.continueTest;
|
||||
delete window.errorTest;
|
||||
});
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
window.unreached = t.unreached_func("Must not reach this");
|
||||
window.continueTest = resolve;
|
||||
window.errorTest = reject;
|
||||
});
|
||||
}
|
||||
|
||||
function assertSuccessful(module) {
|
||||
assert_true(window.evaluated_imports_a, "The module must have been evaluated");
|
||||
assert_equals(module.A.from, "imports-a.js", "The module namespace object must be correct");
|
||||
}
|
||||
|
||||
promise_test(t => {
|
||||
const promise = createTestPromise(t);
|
||||
|
||||
setTimeout(`import('../imports-a.js?label=setTimeout').then(window.unreached, window.continueTest)`, 0);
|
||||
|
||||
return promise.then(assertSuccessful);
|
||||
}, "setTimeout must inherit the nonce from the triggering script, thus execute");
|
||||
|
||||
promise_test(t => {
|
||||
const promise = createTestPromise(t);
|
||||
|
||||
eval(`import('../imports-a.js?label=direct eval').then(window.continueTest, window.errorTest)`);
|
||||
|
||||
return promise.then(assertSuccessful);
|
||||
}, "direct eval must inherit the nonce from the triggering script, thus execute");
|
||||
|
||||
promise_test(t => {
|
||||
const promise = createTestPromise(t);
|
||||
|
||||
const evalAlias = eval;
|
||||
evalAlias(`import('../imports-a.js?label=indirect eval').then(window.continueTest, window.errorTest)`);
|
||||
|
||||
return promise.then(assertSuccessful);
|
||||
}, "indirect eval must inherit the nonce from the triggering script, thus execute");
|
||||
|
||||
promise_test(t => {
|
||||
const promise = createTestPromise(t);
|
||||
|
||||
Function(`import('../imports-a.js?label=the Function constructor').then(window.continueTest, window.errorTest)`)();
|
||||
|
||||
return promise.then(assertSuccessful);
|
||||
}, "the Function constructor must inherit the nonce from the triggering script, thus execute");
|
||||
|
||||
promise_test(t => {
|
||||
t.add_cleanup(() => {
|
||||
dummyDiv.removeAttribute("onclick");
|
||||
});
|
||||
|
||||
const promise = createTestPromise(t);
|
||||
|
||||
// This only works because of the 'unsafe-hashed-attributes' and the hash in the CSP policy
|
||||
dummyDiv.setAttribute(
|
||||
"onclick",
|
||||
`import('../imports-a.js?label=reflected inline event handlers').then(window.continueTest, window.errorTest)`
|
||||
);
|
||||
dummyDiv.onclick();
|
||||
|
||||
return promise.then(assertSuccessful);
|
||||
}, "reflected inline event handlers must inherit the nonce from the triggering script, thus execute");
|
||||
|
||||
promise_test(t => {
|
||||
t.add_cleanup(() => {
|
||||
dummyDiv.removeAttribute("onclick");
|
||||
});
|
||||
|
||||
const promise = createTestPromise(t);
|
||||
|
||||
// This only works because of the 'unsafe-hashed-attributes' and the hash in the CSP policy
|
||||
dummyDiv.setAttribute(
|
||||
"onclick",
|
||||
`import('../imports-a.js?label=inline event handlers triggered via UA code').then(window.continueTest, window.errorTest)`
|
||||
);
|
||||
dummyDiv.click(); // different from **on**click()
|
||||
|
||||
return promise.then(assertSuccessful);
|
||||
}, "inline event handlers triggered via UA code must inherit the nonce from the triggering script, thus execute");
|
||||
</script>
|
|
@ -0,0 +1,102 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>import() inside compiled strings uses the appropriate nonce inside a module script</title>
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
|
||||
<meta http-equiv="content-security-policy" content="script-src 'nonce-correct' 'unsafe-eval' 'unsafe-hashed-attributes' 'sha256-cAMzxBL19bKt4KwKGbxy/ZOFIIjH5AmRjlVbsD5pvNw=' 'sha256-3VjoJYNK/9HJMS8rrZHlqSZgUssDY+GPyc7AU8lNM3k='">
|
||||
|
||||
<script nonce="correct" src="/resources/testharness.js"></script>
|
||||
<script nonce="correct" src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<div id="dummy"></div>
|
||||
|
||||
<script type="module" nonce="correct">
|
||||
const dummyDiv = document.querySelector("#dummy");
|
||||
|
||||
function createTestPromise(t) {
|
||||
t.add_cleanup(() => {
|
||||
delete window.evaluated_imports_a;
|
||||
delete window.unreached;
|
||||
delete window.continueTest;
|
||||
delete window.errorTest;
|
||||
});
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
window.unreached = t.unreached_func("Must not reach this");
|
||||
window.continueTest = resolve;
|
||||
window.errorTest = reject;
|
||||
});
|
||||
}
|
||||
|
||||
function assertSuccessful(module) {
|
||||
assert_true(window.evaluated_imports_a, "The module must have been evaluated");
|
||||
assert_equals(module.A.from, "imports-a.js", "The module namespace object must be correct");
|
||||
}
|
||||
|
||||
promise_test(t => {
|
||||
const promise = createTestPromise(t);
|
||||
|
||||
setTimeout(`import('../imports-a.js?label=setTimeout').then(window.unreached, window.continueTest)`, 0);
|
||||
|
||||
return promise.then(assertSuccessful);
|
||||
}, "setTimeout must inherit the nonce from the triggering script, thus execute");
|
||||
|
||||
promise_test(t => {
|
||||
const promise = createTestPromise(t);
|
||||
|
||||
eval(`import('../imports-a.js?label=direct eval').then(window.continueTest, window.errorTest)`);
|
||||
|
||||
return promise.then(assertSuccessful);
|
||||
}, "direct eval must inherit the nonce from the triggering script, thus execute");
|
||||
|
||||
promise_test(t => {
|
||||
const promise = createTestPromise(t);
|
||||
|
||||
const evalAlias = eval;
|
||||
evalAlias(`import('../imports-a.js?label=indirect eval').then(window.continueTest, window.errorTest)`);
|
||||
|
||||
return promise.then(assertSuccessful);
|
||||
}, "indirect eval must inherit the nonce from the triggering script, thus execute");
|
||||
|
||||
promise_test(t => {
|
||||
const promise = createTestPromise(t);
|
||||
|
||||
Function(`import('../imports-a.js?label=the Function constructor').then(window.continueTest, window.errorTest)`)();
|
||||
|
||||
return promise.then(assertSuccessful);
|
||||
}, "the Function constructor must inherit the nonce from the triggering script, thus execute");
|
||||
|
||||
promise_test(t => {
|
||||
t.add_cleanup(() => {
|
||||
dummyDiv.removeAttribute("onclick");
|
||||
});
|
||||
|
||||
const promise = createTestPromise(t);
|
||||
|
||||
// This only works because of the 'unsafe-hashed-attributes' and the hash in the CSP policy
|
||||
dummyDiv.setAttribute(
|
||||
"onclick",
|
||||
`import('../imports-a.js?label=reflected inline event handlers').then(window.continueTest, window.errorTest)`
|
||||
);
|
||||
dummyDiv.onclick();
|
||||
|
||||
return promise.then(assertSuccessful);
|
||||
}, "reflected inline event handlers must inherit the nonce from the triggering script, thus execute");
|
||||
|
||||
promise_test(t => {
|
||||
t.add_cleanup(() => {
|
||||
dummyDiv.removeAttribute("onclick");
|
||||
});
|
||||
|
||||
const promise = createTestPromise(t);
|
||||
|
||||
// This only works because of the 'unsafe-hashed-attributes' and the hash in the CSP policy
|
||||
dummyDiv.setAttribute(
|
||||
"onclick",
|
||||
`import('../imports-a.js?label=inline event handlers triggered via UA code').then(window.continueTest, window.errorTest)`
|
||||
);
|
||||
dummyDiv.click(); // different from **on**click()
|
||||
|
||||
return promise.then(assertSuccessful);
|
||||
}, "inline event handlers triggered via UA code must inherit the nonce from the triggering script, thus execute");
|
||||
</script>
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of different types of errors</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"network error has higher priority than parse error");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_equals(log.length, 3);
|
||||
|
||||
// A parse error is reported for the first top-level
|
||||
// <script> element for syntaxerror.js.
|
||||
assert_equals(log[0].constructor, SyntaxError);
|
||||
assert_equals(log[1], 1);
|
||||
|
||||
// onerror is called (with no errors reported) due to a network error
|
||||
// for the second top-level <script>.
|
||||
assert_equals(log[2], 2);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="./syntaxerror.js"
|
||||
onerror="unreachable()" onload="log.push(1)"></script>
|
||||
<script type="module" src="./error-type-1.js"
|
||||
onerror="log.push(2)" onload="unreachable()"></script>
|
|
@ -0,0 +1,2 @@
|
|||
import './syntaxerror.js';
|
||||
import './404.js';
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of different types of errors</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"parse error has higher priority than instantiation error");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_equals(log.length, 4);
|
||||
|
||||
// An instantiation error is reported for the first top-level
|
||||
// <script> element for instantiation-error-1.js.
|
||||
assert_equals(log[0].constructor, SyntaxError);
|
||||
assert_equals(log[1], 1);
|
||||
|
||||
// A parse error is reported for the second top-level <script>.
|
||||
assert_equals(log[2].constructor, SyntaxError);
|
||||
assert_equals(log[3], 2);
|
||||
assert_not_equals(log[0], log[2]);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="./instantiation-error-1.js"
|
||||
onerror="unreachable()" onload="log.push(1)"></script>
|
||||
<script type="module" src="./error-type-2.js"
|
||||
onerror="unreachable()" onload="log.push(2)"></script>
|
|
@ -0,0 +1,2 @@
|
|||
import './instantiation-error-1.js';
|
||||
import './syntaxerror.js';
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of different types of errors</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"instantiation error has higher priority than evaluation error");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_equals(log.length, 5);
|
||||
|
||||
// An evaluation error is reported for the first top-level
|
||||
// <script> element for throw.js.
|
||||
assert_equals(log[0], 'throw');
|
||||
assert_true(log[1].foo);
|
||||
assert_equals(log[2], 1);
|
||||
|
||||
// An instantiation error is reported for the second top-level <script>.
|
||||
assert_equals(log[3].constructor, SyntaxError);
|
||||
assert_equals(log[4], 2);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="./throw.js"
|
||||
onerror="unreachable()" onload="log.push(1)"></script>
|
||||
<script type="module" src="./error-type-3.js"
|
||||
onerror="unreachable()" onload="log.push(2)"></script>
|
|
@ -0,0 +1,2 @@
|
|||
import './throw.js';
|
||||
import './instantiation-error-1.js';
|
|
@ -6,17 +6,19 @@
|
|||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that missing exports lead to SyntaxError events on window and " +
|
||||
"load events on script, and that exceptions are remembered");
|
||||
"load events on script");
|
||||
|
||||
window.log = [];
|
||||
window.addEventListener("error", ev => {
|
||||
test_load.step(() => assert_equals(ev.error.constructor, SyntaxError));
|
||||
log.push(ev.message);
|
||||
});
|
||||
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
const exn = log[0];
|
||||
assert_array_equals(log, [exn, 1, exn, 2, exn, 3, exn, 4, exn, 5]);
|
||||
assert_equals(exn.constructor, SyntaxError);
|
||||
const msg = log[0];
|
||||
assert_array_equals(log, [msg, 1, msg, 2, msg, 3, msg, 4, msg, 5]);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
|
|
|
@ -6,17 +6,19 @@
|
|||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that missing exports lead to SyntaxError events on window and " +
|
||||
"load events on script, and that exceptions are remembered");
|
||||
"load events on script");
|
||||
|
||||
window.log = [];
|
||||
window.addEventListener("error", ev => {
|
||||
test_load.step(() => assert_equals(ev.error.constructor, SyntaxError));
|
||||
log.push(ev.message);
|
||||
});
|
||||
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
const exn = log[0];
|
||||
assert_array_equals(log, [exn, 1, exn, 2, exn, 3, exn, 4, exn, 5]);
|
||||
assert_equals(exn.constructor, SyntaxError);
|
||||
const msg = log[0];
|
||||
assert_array_equals(log, [msg, 1, msg, 2, msg, 3, msg, 4, msg, 5]);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
|
|
|
@ -6,17 +6,19 @@
|
|||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that unresolvable cycles lead to SyntaxError events on window " +
|
||||
"and load events on script, and that exceptions are remembered");
|
||||
"and load events on script");
|
||||
|
||||
window.log = [];
|
||||
window.addEventListener("error", ev => {
|
||||
test_load.step(() => assert_equals(ev.error.constructor, SyntaxError));
|
||||
log.push(ev.message);
|
||||
});
|
||||
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
const exn = log[0];
|
||||
assert_array_equals(log, [exn, 1, exn, 2, exn, 3]);
|
||||
assert_equals(exn.constructor, SyntaxError);
|
||||
const msg = log[0];
|
||||
assert_array_equals(log, [msg, 1, msg, 2, msg, 3]);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
|
|
|
@ -7,16 +7,18 @@
|
|||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that loading a graph in which a module is already " +
|
||||
"errored results in that module's error.");
|
||||
"errored results in an error.");
|
||||
|
||||
window.addEventListener("error", ev => {
|
||||
test_load.step(() => assert_equals(ev.error.constructor, SyntaxError));
|
||||
log.push(ev.message);
|
||||
});
|
||||
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
const exn = log[0];
|
||||
assert_array_equals(log, [exn, 1, exn, 2]);
|
||||
assert_equals(exn.constructor, SyntaxError);
|
||||
const msg = log[0];
|
||||
assert_array_equals(log, [msg, 1, msg, 2]);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
|
|
|
@ -6,17 +6,19 @@
|
|||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that loading a graph in which a module is already " +
|
||||
"errored results in that module's error.");
|
||||
"errored results an error.");
|
||||
|
||||
window.log = [];
|
||||
window.addEventListener("error", ev => {
|
||||
test_load.step(() => assert_equals(ev.error.constructor, SyntaxError));
|
||||
log.push(ev.message);
|
||||
});
|
||||
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
const exn = log[0];
|
||||
assert_array_equals(log, [exn, 1, exn, 2]);
|
||||
assert_equals(exn.constructor, SyntaxError);
|
||||
const msg = log[0];
|
||||
assert_array_equals(log, [msg, 1, msg, 2]);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Referrer with the no-referrer policy</title>
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module">
|
||||
|
||||
// "name" parameter is necessary for bypassing the module map.
|
||||
|
||||
import { referrer as referrerSame } from "./resources/referrer-checker.py?name=same";
|
||||
|
||||
import { referrer as referrerRemote } from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/referrer-checker.py?name=remote";
|
||||
|
||||
import { referrer as referrerSameSame } from "./resources/import-referrer-checker.sub.js?name=same_same";
|
||||
|
||||
import { referrer as referrerSameRemote } from "./resources/import-remote-origin-referrer-checker.sub.js?name=same_remote";
|
||||
|
||||
import { referrer as referrerRemoteRemote } from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/import-referrer-checker.sub.js?name=remote_remote";
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerSame, "",
|
||||
"Referrer should not be sent for the same-origin top-level script.");
|
||||
}, "Importing a same-origin top-level script with the no-referrer policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerRemote, "",
|
||||
"Referrer should not be sent for the remote-origin top-level script.");
|
||||
}, "Importing a remote-origin top-level script with the no-referrer policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerSameSame, "",
|
||||
"Referrer should not be sent for the same-origin descendant script.");
|
||||
}, "Importing a same-origin descendant script from a same-origin top-level " +
|
||||
"script with the no-referrer policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerSameRemote, "",
|
||||
"Referrer should not be sent for the remote-origin descendant script.");
|
||||
}, "Importing a remote-origin descendant script from a same-origin top-level " +
|
||||
"script with the no-referrer policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerRemoteRemote, "",
|
||||
"Referrer should not be sent for the remote-origin descendant script.");
|
||||
}, "Importing a remote-origin descendant script from a remote-origin " +
|
||||
"top-level script with the no-referrer policy.");
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,66 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Referrer with the origin-when-cross-origin policy</title>
|
||||
<meta name="referrer" content="origin-when-cross-origin">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module">
|
||||
|
||||
// "name" parameter is necessary for bypassing the module map.
|
||||
|
||||
import { referrer as referrerSame } from "./resources/referrer-checker.py?name=same";
|
||||
|
||||
import { referrer as referrerRemote } from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/referrer-checker.py?name=remote";
|
||||
|
||||
import { referrer as referrerSameSame } from "./resources/import-referrer-checker.sub.js?name=same_same";
|
||||
|
||||
import { referrer as referrerSameRemote } from "./resources/import-remote-origin-referrer-checker.sub.js?name=same_remote";
|
||||
|
||||
import { referrer as referrerRemoteRemote } from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/import-referrer-checker.sub.js?name=remote_remote";
|
||||
|
||||
const origin = (new URL(location.href)).origin + "/";
|
||||
const remoteOrigin = "http://{{domains[www1]}}:{{ports[http][0]}}/";
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerSame, location.href,
|
||||
"Referrer should be sent for the same-origin top-level script.");
|
||||
}, "Importing a same-origin top-level script with the " +
|
||||
"origin-when-cross-origin policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerRemote, origin,
|
||||
"Referrer should be sent for the remote-origin top-level script.");
|
||||
}, "Importing a remote-origin top-level script with the " +
|
||||
"origin-when-cross-origin policy.");
|
||||
|
||||
test(t => {
|
||||
const scriptURL =
|
||||
new URL("resources/import-referrer-checker.sub.js", location.href)
|
||||
assert_equals(
|
||||
referrerSameSame, scriptURL + "?name=same_same",
|
||||
"Referrer should be sent for the same-origin descendant script.");
|
||||
}, "Importing a same-origin descendant script from a same-origin top-level " +
|
||||
"script with the origin-when-cross-origin policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerSameRemote, origin,
|
||||
"Referrer should be sent for the remote-origin descendant script.");
|
||||
}, "Importing a remote-origin descendant script from a same-origin top-level " +
|
||||
"script with the origin-when-cross-origin policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerRemoteRemote, remoteOrigin,
|
||||
"Referrer should be sent for the remote-origin descendant script.");
|
||||
}, "Importing a remote-origin descendant script from a remote-origin " +
|
||||
"top-level script with the origin-when-cross-origin policy.");
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,62 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Referrer with the origin policy</title>
|
||||
<meta name="referrer" content="origin">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module">
|
||||
|
||||
// "name" parameter is necessary for bypassing the module map.
|
||||
|
||||
import { referrer as referrerSame } from "./resources/referrer-checker.py?name=same";
|
||||
|
||||
import { referrer as referrerRemote } from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/referrer-checker.py?name=remote";
|
||||
|
||||
import { referrer as referrerSameSame } from "./resources/import-referrer-checker.sub.js?name=same_same";
|
||||
|
||||
import { referrer as referrerSameRemote } from "./resources/import-remote-origin-referrer-checker.sub.js?name=same_remote";
|
||||
|
||||
import { referrer as referrerRemoteRemote } from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/import-referrer-checker.sub.js?name=remote_remote";
|
||||
|
||||
const origin = (new URL(location.href)).origin + "/";
|
||||
const remoteOrigin = "http://{{domains[www1]}}:{{ports[http][0]}}/";
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerSame, origin,
|
||||
"Referrer should be sent for the same-origin top-level script.");
|
||||
}, "Importing a same-origin top-level script with the origin policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerRemote, origin,
|
||||
"Referrer should be sent for the remote-origin top-level script.");
|
||||
}, "Importing a remote-origin top-level script with the origin policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerSameSame, origin,
|
||||
"Referrer should be sent for the same-origin descendant script.");
|
||||
}, "Importing a same-origin descendant script from a same-origin top-level " +
|
||||
"script with the origin policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerSameRemote, origin,
|
||||
"Referrer should be sent for the remote-origin descendant script.");
|
||||
}, "Importing a remote-origin descendant script from a same-origin top-level " +
|
||||
"script with the origin policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerRemoteRemote, remoteOrigin,
|
||||
"Referrer should be sent for the remote-origin descendant script.");
|
||||
}, "Importing a remote-origin descendant script from a remote-origin " +
|
||||
"top-level script with the origin policy.");
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,62 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Referrer with the same-origin policy</title>
|
||||
<meta name="referrer" content="same-origin">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module">
|
||||
|
||||
// "name" parameter is necessary for bypassing the module map.
|
||||
|
||||
import { referrer as referrerSame } from "./resources/referrer-checker.py?name=same";
|
||||
|
||||
import { referrer as referrerRemote } from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/referrer-checker.py?name=remote";
|
||||
|
||||
import { referrer as referrerSameSame } from "./resources/import-referrer-checker.sub.js?name=same_same";
|
||||
|
||||
import { referrer as referrerSameRemote } from "./resources/import-remote-origin-referrer-checker.sub.js?name=same_remote";
|
||||
|
||||
import { referrer as referrerRemoteRemote } from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/import-referrer-checker.sub.js?name=remote_remote";
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerSame, location.href,
|
||||
"Referrer should be sent for the same-origin top-level script.");
|
||||
}, "Importing a same-origin top-level script with the same-origin policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerRemote, "",
|
||||
"Referrer should not be sent for the remote-origin top-level script.");
|
||||
}, "Importing a remote-origin top-level script with the same-origin policy.");
|
||||
|
||||
test(t => {
|
||||
const path =
|
||||
new URL("resources/import-referrer-checker.sub.js", location.href);
|
||||
assert_equals(
|
||||
referrerSameSame, path + `?name=same_same`,
|
||||
"Referrer should be sent for the same-origin descendant script.");
|
||||
}, "Importing a same-origin descendant script from a same-origin top-level " +
|
||||
"script with the same-origin policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerSameRemote, "",
|
||||
"Referrer should not be sent for the remote-origin descendant script.");
|
||||
}, "Importing a remote-origin descendant script from a same-origin top-level " +
|
||||
"script with the same-origin policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerRemoteRemote, "",
|
||||
"Referrer should not be sent for the remote-origin descendant script " +
|
||||
"even if it is imported from the script in the same remote-origin.");
|
||||
}, "Importing a remote-origin descendant script from a remote-origin " +
|
||||
"top-level script with the same-origin policy.");
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,68 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Referrer with the unsafe-url policy</title>
|
||||
<meta name="referrer" content="unsafe-url">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module">
|
||||
|
||||
// "name" parameter is necessary for bypassing the module map.
|
||||
|
||||
import { referrer as referrerSame } from "./resources/referrer-checker.py?name=same";
|
||||
|
||||
import { referrer as referrerRemote } from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/referrer-checker.py?name=remote";
|
||||
|
||||
import { referrer as referrerSameSame } from "./resources/import-referrer-checker.sub.js?name=same_same";
|
||||
|
||||
import { referrer as referrerSameRemote } from "./resources/import-remote-origin-referrer-checker.sub.js?name=same_remote";
|
||||
|
||||
import { referrer as referrerRemoteRemote } from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/import-referrer-checker.sub.js?name=remote_remote";
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerSame, location.href,
|
||||
"Referrer should be sent for the same-origin top-level script.");
|
||||
}, "Importing a same-origin top-level script with the unsafe-url policy.");
|
||||
|
||||
test(t => {
|
||||
assert_equals(
|
||||
referrerRemote, location.href,
|
||||
"Referrer should be sent for the remote-origin top-level script.");
|
||||
}, "Importing a remote-origin top-level script with the unsafe-url policy.");
|
||||
|
||||
test(t => {
|
||||
const scriptURL =
|
||||
new URL("resources/import-referrer-checker.sub.js", location.href)
|
||||
assert_equals(
|
||||
referrerSameSame, scriptURL + "?name=same_same",
|
||||
"Referrer should be sent for the same-origin descendant script.");
|
||||
}, "Importing a same-origin descendant script from a same-origin top-level " +
|
||||
"script with the unsafe-url policy.");
|
||||
|
||||
test(t => {
|
||||
const scriptURL =
|
||||
new URL("resources/import-remote-origin-referrer-checker.sub.js",
|
||||
location.href)
|
||||
assert_equals(
|
||||
referrerSameRemote, scriptURL + "?name=same_remote",
|
||||
"Referrer should be sent for the remote-origin descendant script.");
|
||||
}, "Importing a remote-origin descendant script from a same-origin top-level " +
|
||||
"script with the unsafe-url policy.");
|
||||
|
||||
test(t => {
|
||||
const scriptURL =
|
||||
"http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/" +
|
||||
"scripting-1/the-script-element/module/resources/" +
|
||||
"import-referrer-checker.sub.js";
|
||||
assert_equals(
|
||||
referrerRemoteRemote, scriptURL + "?name=remote_remote",
|
||||
"Referrer should be sent for the remote-origin descendant script.");
|
||||
}, "Importing a remote-origin descendant script from a remote-origin " +
|
||||
"top-level script with the unsafe-url policy.");
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,2 @@
|
|||
import { referrer as referrerImport } from './referrer-checker.py?name={{GET[name]}}';
|
||||
export const referrer = referrerImport;
|
|
@ -0,0 +1 @@
|
|||
Access-Control-Allow-Origin: *
|
|
@ -0,0 +1,2 @@
|
|||
import { referrer as referrerImport } from 'http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/referrer-checker.py?name={{GET[name]}}';
|
||||
export const referrer = referrerImport;
|
|
@ -0,0 +1,6 @@
|
|||
def main(request, response):
|
||||
referrer = request.headers.get("referer", "")
|
||||
response_headers = [("Content-Type", "text/javascript"),
|
||||
("Access-Control-Allow-Origin", "*")];
|
||||
return (200, response_headers,
|
||||
"export const referrer = '" + referrer + "';")
|
|
@ -0,0 +1,2 @@
|
|||
log.push("throw2");
|
||||
throw {bar: true}
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML Test: HTMLScriptElement - defer</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<script>
|
||||
|
||||
let script_run_status = "inline";
|
||||
let t = async_test("the defer script run later");
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="defer.js" defer></script>
|
||||
|
||||
<script>
|
||||
|
||||
t.step(() => {
|
||||
assert_equals(script_run_status, "inline", "the script run status");
|
||||
script_run_status = "deferred";
|
||||
});
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue