mirror of
https://github.com/lexmount/moli.git
synced 2026-11-17 16:09:13 +00:00
fix(trusted-types): recognize fullscreen event handlers
This commit is contained in:
@@ -3281,6 +3281,7 @@ service-workers/service-worker/referrer-policy-header.https.html
|
||||
service-workers/service-worker/registration-schedule-job.https.html
|
||||
service-workers/service-worker/registration-scope-module-static-import.https.html
|
||||
service-workers/service-worker/registration-scope.https.html
|
||||
service-workers/service-worker/registration-script-url.https.html
|
||||
service-workers/service-worker/request-end-to-end.https.html
|
||||
service-workers/service-worker/resource-timing-cross-origin.https.html
|
||||
service-workers/service-worker/sandboxed-iframe-navigator-serviceworker.https.html
|
||||
|
||||
@@ -8885,7 +8885,6 @@ service-workers/service-worker/registration-basic.https.html
|
||||
service-workers/service-worker/registration-end-to-end.https.html
|
||||
service-workers/service-worker/registration-events.https.html
|
||||
service-workers/service-worker/registration-iframe.https.html
|
||||
service-workers/service-worker/registration-script-url.https.html
|
||||
service-workers/service-worker/rejections.https.html
|
||||
service-workers/service-worker/respond-with-body-accessed-response.https.html
|
||||
service-workers/service-worker/serviceworker-message-event-historical.https.html
|
||||
|
||||
@@ -1497,7 +1497,7 @@ pub(crate) fn install_element_template_bindings<'s>(
|
||||
install_node_event_handler_template_bindings(
|
||||
scope,
|
||||
prototype,
|
||||
&["onfullscreenchange", "onfullscreenerror"],
|
||||
event_handlers::ELEMENT_FULLSCREEN_EVENT_HANDLER_PROPERTIES,
|
||||
);
|
||||
}
|
||||
"Document" => install!(DocumentCustomElementRegistryPrototypeDeclaration),
|
||||
|
||||
@@ -119,15 +119,19 @@ pub(crate) const GENERIC_EVENT_HANDLER_PROPERTIES: &[&str] = &[
|
||||
"onwebkittransitionend",
|
||||
];
|
||||
|
||||
const ON_FULLSCREEN_CHANGE: &str = "onfullscreenchange";
|
||||
const ON_FULLSCREEN_ERROR: &str = "onfullscreenerror";
|
||||
const DOCUMENT_EVENT_HANDLER_PROPERTIES: &[&str] = &[
|
||||
"onfreeze",
|
||||
"onfullscreenchange",
|
||||
"onfullscreenerror",
|
||||
ON_FULLSCREEN_CHANGE,
|
||||
ON_FULLSCREEN_ERROR,
|
||||
"onpointerlockchange",
|
||||
"onpointerlockerror",
|
||||
"onreadystatechange",
|
||||
"onresume",
|
||||
];
|
||||
pub(in crate::native_bridge::element) const ELEMENT_FULLSCREEN_EVENT_HANDLER_PROPERTIES: &[&str] =
|
||||
&[ON_FULLSCREEN_CHANGE, ON_FULLSCREEN_ERROR];
|
||||
const ELEMENT_SPECIFIC_EVENT_HANDLER_PROPERTIES: &[&str] = &[
|
||||
"onencrypted",
|
||||
"onwaitingforkey",
|
||||
@@ -142,6 +146,7 @@ pub(in crate::native_bridge::element) fn is_element_event_handler_content_attrib
|
||||
GENERIC_EVENT_HANDLER_PROPERTIES
|
||||
.iter()
|
||||
.chain(WINDOW_EVENT_HANDLER_PROPERTIES)
|
||||
.chain(ELEMENT_FULLSCREEN_EVENT_HANDLER_PROPERTIES)
|
||||
.chain(ELEMENT_SPECIFIC_EVENT_HANDLER_PROPERTIES)
|
||||
.copied()
|
||||
.chain(["onmessageerror"])
|
||||
|
||||
@@ -8,7 +8,9 @@ pub(crate) use body_window::{
|
||||
install_body_or_frameset_window_event_handler_accessors,
|
||||
resolve_window_event_handler_content_attribute,
|
||||
};
|
||||
pub(super) use generic::is_element_event_handler_content_attribute_name;
|
||||
pub(super) use generic::{
|
||||
ELEMENT_FULLSCREEN_EVENT_HANDLER_PROPERTIES, is_element_event_handler_content_attribute_name,
|
||||
};
|
||||
pub(crate) use generic::{
|
||||
GlobalEventHandlerOwner, canonical_event_handler_event_type,
|
||||
event_handler_content_attribute_name, install_global_event_handler_template_bindings,
|
||||
|
||||
@@ -17,7 +17,7 @@ async fn unsupported_fullscreen_requests_reject_and_queue_spec_shaped_error_even
|
||||
globalThis.__fullscreenConversionRejections = [];
|
||||
globalThis.__fullscreenOptionReads = [];
|
||||
document.body.setAttribute("onfullscreenerror", "globalThis.__fullscreenAttributeRan = true");
|
||||
const contentAttributeIgnored = document.body.onfullscreenerror === null;
|
||||
const contentAttributeInstalled = typeof document.body.onfullscreenerror === "function";
|
||||
document.onfullscreenerror = event => {
|
||||
__fullscreenEvents.push([
|
||||
event.type,
|
||||
@@ -87,7 +87,7 @@ async fn unsupported_fullscreen_requests_reject_and_queue_spec_shaped_error_even
|
||||
],
|
||||
promises: request instanceof Promise && exit instanceof Promise,
|
||||
conversionPromiseShapes,
|
||||
contentAttributeIgnored,
|
||||
contentAttributeInstalled,
|
||||
optionReads: __fullscreenOptionReads,
|
||||
wrongReceivers: [
|
||||
outcome(() => Element.prototype.requestFullscreen.call({})),
|
||||
@@ -102,7 +102,7 @@ async fn unsupported_fullscreen_requests_reject_and_queue_spec_shaped_error_even
|
||||
|
||||
assert_eq!(
|
||||
before,
|
||||
r#"{"requestShape":["function",0,true,true],"documentShape":["function",0,true,true,false],"promises":true,"conversionPromiseShapes":[true,true,true,true],"contentAttributeIgnored":true,"optionReads":["keyboardLock","navigationUI"],"wrongReceivers":["TypeError","TypeError"],"events":0}"#,
|
||||
r#"{"requestShape":["function",0,true,true],"documentShape":["function",0,true,true,false],"promises":true,"conversionPromiseShapes":[true,true,true,true],"contentAttributeInstalled":true,"optionReads":["keyboardLock","navigationUI"],"wrongReceivers":["TypeError","TypeError"],"events":0}"#,
|
||||
);
|
||||
|
||||
vm.advance_timers_until_deadline_for_test(&loader)
|
||||
@@ -123,6 +123,6 @@ JSON.stringify({
|
||||
.expect("fullscreen rejection result should evaluate");
|
||||
assert_eq!(
|
||||
after,
|
||||
r#"{"events":["fullscreenerror:true:true:false:true"],"rejections":["exit:TypeError","request:TypeError"],"conversionRejections":["enum:TypeError:true","getter:RangeError:true","number:TypeError:true","string:TypeError:true"],"contentAttributeRan":false}"#,
|
||||
r#"{"events":["fullscreenerror:true:true:false:true"],"rejections":["exit:TypeError","request:TypeError"],"conversionRejections":["enum:TypeError:true","getter:RangeError:true","number:TypeError:true","string:TypeError:true"],"contentAttributeRan":true}"#,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1583,7 +1583,12 @@ fn event_handler_attribute_writes_enforce_trusted_script_at_the_attribute_bounda
|
||||
ordinary.setAttributeNS("urn:test", "onclick", "plain-namespaced");
|
||||
const uppercaseSvg = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
||||
uppercaseSvg.setAttributeNS(null, "ONCLICK", "plain-uppercase");
|
||||
const elementSpecificRejected = ["onwaitingforkey", "onbegin"].map(name => {
|
||||
const elementSpecificRejected = [
|
||||
"onwaitingforkey",
|
||||
"onbegin",
|
||||
"onfullscreenchange",
|
||||
"onfullscreenerror"
|
||||
].map(name => {
|
||||
try {
|
||||
document.createElement("div").setAttribute(name, "plain-special");
|
||||
return false;
|
||||
@@ -1629,7 +1634,7 @@ fn event_handler_attribute_writes_enforce_trusted_script_at_the_attribute_bounda
|
||||
|
||||
assert_eq!(
|
||||
result,
|
||||
r#"{"runs":["trusted","trusted-ns","default"],"unsuitableRejected":true,"unsuitableAttribute":null,"plainRejected":true,"plainAttribute":null,"plainNsRejected":true,"plainNsAttribute":null,"ordinary":["plain-data","plain-unknown","plain-namespaced","plain-uppercase"],"elementSpecificRejected":[true,true],"defaultedAttribute":"globalThis.__eventHandlerAttributeRuns.push('default')","defaultCalls":[["default-input","TrustedScript","Element onclick"]]}"#
|
||||
r#"{"runs":["trusted","trusted-ns","default"],"unsuitableRejected":true,"unsuitableAttribute":null,"plainRejected":true,"plainAttribute":null,"plainNsRejected":true,"plainNsAttribute":null,"ordinary":["plain-data","plain-unknown","plain-namespaced","plain-uppercase"],"elementSpecificRejected":[true,true,true,true],"defaultedAttribute":"globalThis.__eventHandlerAttributeRuns.push('default')","defaultCalls":[["default-input","TrustedScript","Element onclick"]]}"#
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user