Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Gecko Bug 1939866] Fix some assertions for trusted type sink tests. #49909

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions trusted-types/default-policy-callback-arguments.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@
assert_equals(args[0], current_case[0], "Expecting the value.");
assert_equals(args[1], current_case[1], "Expecting the type name.");
assert_equals(args[2], current_case[2], "Expecting the sink name.");
switch (args[1]) {
case TrustedScriptURL:
assert_equals(args[2], 'HTMLScriptElement src');
break;
case TrustedHTML:
assert_equals(args[2], 'Element innerHTML');
break;
case TrustedScript:
assert_equals(args[2], 'HTMLScriptElement text');
break;
}
return args[0];
}

Expand Down
12 changes: 7 additions & 5 deletions trusted-types/default-policy-report-only.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
});

// A trusted type policy that forces a number of edge cases.
function policy(str, type, sink) {
function policy(str, trustedTypeName, sink) {
if (str == "throw")
throw RangeError();
else if (str == "null")
Expand All @@ -66,16 +66,18 @@
else if (str == "done")
return null;
else {
switch (type) {
case TrustedScriptURL:
switch (trustedTypeName) {
case "TrustedScriptURL":
assert_equals(sink, 'HTMLScriptElement src');
break;
case TrustedHTML:
case "TrustedHTML":
assert_equals(sink, 'Element innerHTML');
break;
case TrustedScript:
case "TrustedScript":
assert_equals(sink, 'HTMLScriptElement text');
break;
default:
assert_unreached(`Unknown trusted type name '${trustedTypeName}'`);
}
return "sanitized: " + str;
}
Expand Down
12 changes: 7 additions & 5 deletions trusted-types/default-policy.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
});

// A trusted type policy that forces a number of edge cases.
function policy(str, type, sink) {
function policy(str, trustedTypeName, sink) {
if (str == "throw")
throw RangeError();
else if (str == "null")
Expand All @@ -66,16 +66,18 @@
else if (str == "done")
return null;
else {
switch (type) {
case TrustedScriptURL:
switch (trustedTypeName) {
case "TrustedScriptURL":
assert_equals(sink, 'HTMLScriptElement src');
break;
case TrustedHTML:
case "TrustedHTML":
assert_equals(sink, 'Element innerHTML');
break;
case TrustedScript:
case "TrustedScript":
assert_equals(sink, 'HTMLScriptElement text');
break;
default:
assert_unreached(`Unknown trusted type name '${trustedTypeName}'`);
}
return "sanitized: " + str;
}
Expand Down