Auto merge of #28542 - yvt:fix-dedicated-worker-environment-origin, r=jdm

Set `DedicatedWorkerGlobalScope`'s origin correctly

<https://html.spec.whatwg.org/multipage/workers.html#script-settings-for-workers>

> To **set up a worker environment settings object**, given a JavaScript execution context *execution context* and environment settings object *outside settings*: [...]
>
> 4. Let *settings object* be a new environment settings object whose algorithms are defined as follows:
>
>    **The origin** Return a unique opaque origin if *worker global scope*'s url's scheme is "data", and *inherited origin* otherwise.

---
- [x] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)

---
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___
This commit is contained in:
bors-servo 2021-07-13 07:49:47 -04:00 committed by GitHub
commit c5ed0430bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 20 deletions

View file

@ -53,7 +53,7 @@ use net_traits::IpcSend;
use parking_lot::Mutex;
use script_traits::{WorkerGlobalScopeInit, WorkerScriptLoadOrigin};
use servo_rand::random;
use servo_url::ServoUrl;
use servo_url::{ImmutableOrigin, ServoUrl};
use std::mem::replace;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
@ -310,7 +310,7 @@ impl DedicatedWorkerGlobalScope {
#[allow(unsafe_code)]
// https://html.spec.whatwg.org/multipage/#run-a-worker
pub fn run_worker_scope(
init: WorkerGlobalScopeInit,
mut init: WorkerGlobalScopeInit,
worker_url: ServoUrl,
from_devtools_receiver: IpcReceiver<DevtoolScriptControlMsg>,
worker: TrustedWorkerAddress,
@ -387,6 +387,17 @@ impl DedicatedWorkerGlobalScope {
devtools_mpsc_chan,
);
// Step 8 "Set up a worker environment settings object [...]"
//
// <https://html.spec.whatwg.org/multipage/#script-settings-for-workers>
//
// > The origin: Return a unique opaque origin if `worker global
// > scope`'s url's scheme is "data", and `inherited origin`
// > otherwise.
if worker_url.scheme() == "data" {
init.origin = ImmutableOrigin::new_opaque();
}
let global = DedicatedWorkerGlobalScope::new(
init,
DOMString::from_string(worker_name),
@ -453,7 +464,7 @@ impl DedicatedWorkerGlobalScope {
.mem_profiler_chan()
.run_with_memory_reporting(
|| {
// Step 29, Run the responsible event loop specified
// Step 27, Run the responsible event loop specified
// by inside settings until it is destroyed.
// The worker processing model remains on this step
// until the event loop is destroyed,

View file

@ -280,7 +280,7 @@ impl ServiceWorkerGlobalScope {
}
#[allow(unsafe_code)]
// https://html.spec.whatwg.org/multipage/#run-a-worker
// https://w3c.github.io/ServiceWorker/#run-service-worker-algorithm
pub fn run_serviceworker_scope(
scope_things: ScopeThings,
own_sender: Sender<ServiceWorkerScriptMsg>,
@ -382,7 +382,7 @@ impl ServiceWorkerGlobalScope {
.mem_profiler_chan()
.run_with_memory_reporting(
|| {
// Step 29, Run the responsible event loop specified
// Step 18, Run the responsible event loop specified
// by inside settings until it is destroyed.
// The worker processing model remains on this step
// until the event loop is destroyed,

View file

@ -1,4 +0,0 @@
[dedicated-worker-in-data-url-context.window.html]
[Create a dedicated worker in a data url dedicated worker]
expected: FAIL

View file

@ -1,4 +0,0 @@
[data-url-worker.html]
[fetching "top.txt" without ACAO should be rejected.]
expected: FAIL

View file

@ -3,9 +3,6 @@
[Same Origin SharedWorker]
expected: FAIL
[Data Url Worker]
expected: FAIL
[Data Url SharedWorker]
expected: FAIL

View file

@ -1,4 +0,0 @@
[dedicated-worker-in-data-url-context.window.html]
[Create a dedicated worker in a data url dedicated worker]
expected: FAIL