Skip to content

Commit

Permalink
Move some test input data from the test to the input data
Browse files Browse the repository at this point in the history
Preparation for adding MutationObserver tests to the same file.
See the following commits.
  • Loading branch information
mbrodesser-Igalia committed Feb 20, 2024
1 parent 2898a8f commit 3a15f9f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions trusted-types/block-string-assignment-to-Element-setAttribute.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

// TrustedScriptURL Assignments
const scriptURLTestCases = [
[ 'embed', 'src' ],
[ 'object', 'data' ],
[ 'object', 'codeBase' ],
[ 'script', 'src' ]
[ 'embed', 'src', INPUTS.SCRIPTURL, RESULTS.SCRIPTURL],
[ 'object', 'data', INPUTS.SCRIPTURL, RESULTS.SCRIPTURL ],
[ 'object', 'codeBase', INPUTS.SCRIPTURL, RESULTS.SCRIPTURL ],
[ 'script', 'src', INPUTS.SCRIPTURL, RESULTS.SCRIPTURL ]
];

scriptURLTestCases.forEach(c => {
Expand All @@ -31,12 +31,12 @@

// TrustedHTML Assignments
const HTMLTestCases = [
[ 'iframe', 'srcdoc' ]
[ 'iframe', 'srcdoc' , INPUTS.HTML, RESULTS.HTML]
];

HTMLTestCases.forEach(c => {
test(t => {
assert_element_accepts_trusted_html_explicit_set(window, c[0] + "-" + c[1], t, c[0], c[1], RESULTS.HTML);
assert_element_accepts_trusted_html_explicit_set(window, c[0] + "-" + c[1], t, c[0], c[1], c[3]);
assert_throws_no_trusted_type_explicit_set(c[0], c[1], 'A string');
assert_throws_no_trusted_type_explicit_set(c[0], c[1], null);
assert_throws_no_trusted_type_explicit_set(c[0], c[1], nullPolicy.createScript('script'));
Expand All @@ -45,12 +45,12 @@

// TrustedScript Assignments
const ScriptTestCases = [
[ 'div', 'onclick' ]
[ 'div', 'onclick' , INPUTS.SCRIPT, RESULTS.SCRIPT]
];

ScriptTestCases.forEach(c => {
test(t => {
assert_element_accepts_trusted_script_explicit_set(window, c[0] + "-" + c[1], t, c[0], c[1], RESULTS.SCRIPT);
assert_element_accepts_trusted_script_explicit_set(window, c[0] + "-" + c[1], t, c[0], c[1], c[3]);
assert_throws_no_trusted_type_explicit_set(c[0], c[1], 'A string');
assert_throws_no_trusted_type_explicit_set(c[0], c[1], null);
}, c[0] + "." + c[1] + " accepts only TrustedScript");
Expand All @@ -70,21 +70,21 @@
let p = window.trustedTypes.createPolicy("default", { createScriptURL: createScriptURLJS, createHTML: createHTMLJS, createScript: createScriptJS }, true);
scriptURLTestCases.forEach(c => {
test(t => {
assert_element_accepts_trusted_type(c[0], c[1], INPUTS.SCRIPTURL, RESULTS.SCRIPTURL);
assert_element_accepts_trusted_type(c[0], c[1], c[2], c[3]);
assert_element_accepts_trusted_type(c[0], c[1], null, window.location.toString().replace(/[^\/]*$/, "null"));
}, c[0] + "." + c[1] + " accepts string and null after default policy was created.");
});

HTMLTestCases.forEach(c => {
test(t => {
assert_element_accepts_trusted_type(c[0], c[1], INPUTS.HTML, RESULTS.HTML);
assert_element_accepts_trusted_type(c[0], c[1], c[2], c[3]);
assert_element_accepts_trusted_type(c[0], c[1], null, "null");
}, c[0] + "." + c[1] + " accepts string and null after default policy was created.");
});

ScriptTestCases.forEach(c => {
test(t => {
assert_element_accepts_trusted_type_explicit_set(c[0], c[1], INPUTS.SCRIPT, RESULTS.SCRIPT);
assert_element_accepts_trusted_type_explicit_set(c[0], c[1], c[2], c[3]);
assert_element_accepts_trusted_type_explicit_set(c[0], c[1], null, "null");
}, c[0] + "." + c[1] + " accepts string and null after default policy was created.");
});
Expand Down

0 comments on commit 3a15f9f

Please sign in to comment.