feat(script): use GlobalScope::origin when creating a principals object

The concrete types of `[Global]` DOM interfaces have `origin` methods,
which were used before this commit. Some of them just delegate to
`GlobalScope::origin` while others are implemented differently. This
commit changes the created principals objects' associated origins in the
following way:

 - `DedicatedWorkerGlobalScope` - was `WorkerGlobalScope::worker_url`
 - `DissimilarOriginWindow` - no change
 - `PaintWorkletGlobalScope` - no change
 - `ServiceWorkerGlobalScope` - was `ServiceWorkerGlobalScope::scope_url`
 - `TestWorkletGlobalScope` - no change
 - `Window` - no change
This commit is contained in:
yvt 2021-07-13 20:53:53 +09:00
parent 3550270cd0
commit c3de9b72a6

View file

@ -2912,7 +2912,7 @@ class CGWrapGlobalMethod(CGAbstractMethod):
return CGGeneric("""\
let raw = Root::new(MaybeUnreflectedDom::from_box(object));
let origin = (*raw.as_ptr()).origin(); // `MutableOrigin` or `&MutableOrigin`
let origin = (*raw.as_ptr()).upcast::<GlobalScope>().origin();
rooted!(in(*cx) let mut obj = ptr::null_mut::<JSObject>());
create_global_object(
@ -2921,7 +2921,7 @@ create_global_object(
raw.as_ptr() as *const %(concreteType)s as *const libc::c_void,
_trace,
obj.handle_mut(),
&origin);
origin);
assert!(!obj.is_null());
let root = raw.reflect_with(obj.get());