Auto merge of #23351 - CYBAI:fix-modes, r=nox

Fix modes for fetching classic worker script and introduce parser metadata for request

While reading [the spec](https://html.spec.whatwg.org/multipage/#fetch-a-classic-worker-script) for `fetch a classic worker script`, I found the `mode` and `credential-mode` are opposite to the spec. So, the first commit will fix it.

Also, I found there's a `parser metadata` for `request` so I tried to introduce it in this PR as well.

For WPT, I found there's a `/workers/constructors/Worker/same-origin.html` which was disabled in  #3180. We pass most of the tests now.

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

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23351)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-05-16 00:19:40 -04:00 committed by GitHub
commit 425686984d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 5 deletions

View file

@ -38,7 +38,8 @@ use js::jsapi::{JSAutoRealm, JSContext};
use js::jsval::UndefinedValue;
use js::rust::HandleValue;
use msg::constellation_msg::{PipelineId, TopLevelBrowsingContextId};
use net_traits::request::{CredentialsMode, Destination, Referrer, RequestBuilder};
use net_traits::request::{CredentialsMode, Destination, ParserMetadata};
use net_traits::request::{Referrer, RequestBuilder, RequestMode};
use net_traits::IpcSend;
use script_traits::{TimerEvent, TimerSource, WorkerGlobalScopeInit, WorkerScriptLoadOrigin};
use servo_rand::random;
@ -321,7 +322,9 @@ impl DedicatedWorkerGlobalScope {
let request = RequestBuilder::new(worker_url.clone())
.destination(Destination::Worker)
.credentials_mode(CredentialsMode::Include)
.mode(RequestMode::SameOrigin)
.credentials_mode(CredentialsMode::CredentialsSameOrigin)
.parser_metadata(ParserMetadata::NotParserInserted)
.use_url_credentials(true)
.pipeline_id(pipeline_id)
.referrer(referrer)

View file

@ -32,7 +32,7 @@ use ipc_channel::router::ROUTER;
use js::jsapi::{JSAutoRealm, JSContext, JS_AddInterruptCallback};
use js::jsval::UndefinedValue;
use msg::constellation_msg::PipelineId;
use net_traits::request::{CredentialsMode, Destination, Referrer, RequestBuilder};
use net_traits::request::{CredentialsMode, Destination, ParserMetadata, Referrer, RequestBuilder};
use net_traits::{CustomResponseMediator, IpcSend};
use script_traits::{
ScopeThings, ServiceWorkerMsg, TimerEvent, WorkerGlobalScopeInit, WorkerScriptLoadOrigin,
@ -290,6 +290,7 @@ impl ServiceWorkerGlobalScope {
let request = RequestBuilder::new(script_url.clone())
.destination(Destination::ServiceWorker)
.credentials_mode(CredentialsMode::Include)
.parser_metadata(ParserMetadata::NotParserInserted)
.use_url_credentials(true)
.pipeline_id(pipeline_id)
.referrer(referrer)

View file

@ -43,7 +43,9 @@ use js::jsval::UndefinedValue;
use js::panic::maybe_resume_unwind;
use js::rust::{HandleValue, ParentRuntime};
use msg::constellation_msg::PipelineId;
use net_traits::request::{CredentialsMode, Destination, RequestBuilder as NetRequestInit};
use net_traits::request::{
CredentialsMode, Destination, ParserMetadata, RequestBuilder as NetRequestInit,
};
use net_traits::IpcSend;
use script_traits::WorkerGlobalScopeInit;
use script_traits::{TimerEvent, TimerEventId};
@ -224,6 +226,7 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
let request = NetRequestInit::new(url.clone())
.destination(Destination::Script)
.credentials_mode(CredentialsMode::Include)
.parser_metadata(ParserMetadata::NotParserInserted)
.use_url_credentials(true)
.origin(global_scope.origin().immutable().clone())
.pipeline_id(Some(self.upcast::<GlobalScope>().pipeline_id()))

View file

@ -124,6 +124,7 @@ fn request_init_from_request(request: NetTraitsRequest) -> RequestBuilder {
redirect_mode: request.redirect_mode,
integrity_metadata: "".to_owned(),
url_list: vec![],
parser_metadata: request.parser_metadata,
}
}