mirror of
https://github.com/lexmount/moli.git
synced 2026-11-22 00:02:21 +00:00
fix(workers): dispatch intrinsic bootstrap error events
Use trusted plain Events with default flags for worker loading, parsing, and SharedWorker connection failures, without invoking author constructors or exposing ErrorEvent-only details. Keep nested bootstrap failures out of runtime error propagation. Cover native event construction, author hooks, CSP blocking, callback ordering, and startup-versus-runtime behavior in Rust and ported WPT fixtures.
This commit is contained in:
@@ -1635,12 +1635,16 @@ async fn nested_worker_constructor_csp_block_is_async_and_reports_to_parent_glob
|
||||
constructed: false,
|
||||
violation: null,
|
||||
error: null,
|
||||
ping: false
|
||||
ping: false,
|
||||
globalErrors: 0
|
||||
};
|
||||
onerror = () => { ++result.globalErrors; return true; };
|
||||
function finish() {
|
||||
if (result.violation && result.error) {
|
||||
postMessage(result);
|
||||
close();
|
||||
setTimeout(() => {
|
||||
postMessage(result);
|
||||
close();
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
const child = new Worker("data:text/javascript,postMessage('ping')");
|
||||
@@ -1665,8 +1669,12 @@ async fn nested_worker_constructor_csp_block_is_async_and_reports_to_parent_glob
|
||||
child.addEventListener("error", event => {
|
||||
event.preventDefault();
|
||||
result.error = {
|
||||
messageIncludesCsp: event.message.includes("Content Security Policy"),
|
||||
filename: event.filename
|
||||
type: event.type,
|
||||
intrinsicEvent: Object.getPrototypeOf(event) === Event.prototype,
|
||||
target: event.target === child,
|
||||
trusted: event.isTrusted,
|
||||
flags: [event.bubbles, event.cancelable, event.composed, event.defaultPrevented],
|
||||
hasErrorDetails: ['message', 'filename', 'lineno', 'colno', 'error'].some(name => name in event)
|
||||
};
|
||||
finish();
|
||||
});
|
||||
@@ -1680,7 +1688,7 @@ async fn nested_worker_constructor_csp_block_is_async_and_reports_to_parent_glob
|
||||
|
||||
assert_eq!(
|
||||
recv_post_json(&mut handle).await,
|
||||
r#"{"constructed":true,"violation":{"type":"securitypolicyviolation","effectiveDirective":"worker-src","violatedDirective":"worker-src","blockedURI":"data","documentURI":"https://app.example/parent.js","originalPolicy":"worker-src 'none'","disposition":"enforce","instance":true},"error":{"messageIncludesCsp":true,"filename":"data:text/javascript,postMessage('ping')"},"ping":false}"#
|
||||
r#"{"constructed":true,"violation":{"type":"securitypolicyviolation","effectiveDirective":"worker-src","violatedDirective":"worker-src","blockedURI":"data","documentURI":"https://app.example/parent.js","originalPolicy":"worker-src 'none'","disposition":"enforce","instance":true},"error":{"type":"error","intrinsicEvent":true,"target":true,"trusted":true,"flags":[false,false,false,false],"hasErrorDetails":false},"ping":false,"globalErrors":0}"#
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user