From 8b2892113693e6d2eddfc29dd49bbf7d54954912 Mon Sep 17 00:00:00 2001 From: CYBAI Date: Mon, 7 May 2018 20:31:29 +0800 Subject: [PATCH 01/20] Make expectionCode of Promise have newline character automatically In the `fill` method, it will check if the exception code is empty string or has newline character in the end of string or not. However, we didn't do any change to exceptionCode when type is Promise. Thus, we add the newline character to make it pass the checking in `fill` method. See more detail from the log of IRC: https://mozilla.logbot.info/servo/20180501#c14692647 --- components/script/dom/bindings/codegen/CodegenRust.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index fd2df0799c6..c9271bb03dc 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -6207,7 +6207,7 @@ class CGDictionary(CGThing): descriptorProvider, isMember="Dictionary", defaultValue=member.defaultValue, - exceptionCode="return Err(());")) + exceptionCode="return Err(());\n")) for member in dictionary.members] def define(self): From 924a78c6c678e9448df9983bb370ff40910465bd Mon Sep 17 00:00:00 2001 From: CYBAI Date: Mon, 7 May 2018 20:36:18 +0800 Subject: [PATCH 02/20] Implement unhandledrejection event --- Cargo.lock | 14 +- components/atoms/static_atoms.txt | 1 + components/malloc_size_of/Cargo.toml | 2 +- components/script/Cargo.toml | 2 +- components/script/dom/globalscope.rs | 58 +++++++- components/script/dom/mod.rs | 1 + components/script/dom/promise.rs | 2 +- .../script/dom/promiserejectionevent.rs | 114 ++++++++++++++++ .../dom/webidls/PromiseRejectionEvent.webidl | 16 +++ components/script/microtask.rs | 14 +- components/script/script_runtime.rs | 128 +++++++++++++++++- components/script/script_thread.rs | 10 +- 12 files changed, 342 insertions(+), 20 deletions(-) create mode 100644 components/script/dom/promiserejectionevent.rs create mode 100644 components/script/dom/webidls/PromiseRejectionEvent.webidl diff --git a/Cargo.lock b/Cargo.lock index 8508834d885..cd5bca3d7e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2026,7 +2026,7 @@ dependencies = [ "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "keyboard-types 0.4.2-servo (registry+https://github.com/rust-lang/crates.io-index)", - "mozjs 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "mozjs 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.20.0", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2227,20 +2227,20 @@ dependencies = [ [[package]] name = "mozjs" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "mozjs_sys 0.61.0 (registry+https://github.com/rust-lang/crates.io-index)", + "mozjs_sys 0.61.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "mozjs_sys" -version = "0.61.0" +version = "0.61.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bindgen 0.39.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3004,7 +3004,7 @@ dependencies = [ "mime_guess 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "mozangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "mozjs 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "mozjs 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "net_traits 0.0.1", "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4505,8 +4505,8 @@ dependencies = [ "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9de3eca27871df31c33b807f834b94ef7d000956f57aa25c5aed9c5f0aae8f6f" "checksum mozangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "45a8a18a41cfab0fde25cc2f43ea89064d211a0fbb33225b8ff93ab20406e0e7" -"checksum mozjs 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b9f85c1120b07d7a2acc9d1d62df1fe16f64162399448fb5307bf2bc3bd066c9" -"checksum mozjs_sys 0.61.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ff07b0f0a2371dc08d75d55371ca311be67e1fdfa6c146fc8ad154c340f70c9" +"checksum mozjs 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bd0bdded611cb03c8ca638e0b663befe67eb7fbcb1fe2dfd25061656ee4ff365" +"checksum mozjs_sys 0.61.1 (registry+https://github.com/rust-lang/crates.io-index)" = "070dd9dcd0be8b524fe4f6fcc791d56d630518652f98c2b152fdebe28eb71a5b" "checksum msdos_time 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aad9dfe950c057b1bfe9c1f2aa51583a8468ef2a5baba2ebbe06d775efeb7729" "checksum muldiv 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "451a9a05d2a32c566c897835e0ea95cf79ed2fdfe957924045a1721a36c9980f" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" diff --git a/components/atoms/static_atoms.txt b/components/atoms/static_atoms.txt index 4281c7004d0..f123a2b66c5 100644 --- a/components/atoms/static_atoms.txt +++ b/components/atoms/static_atoms.txt @@ -86,6 +86,7 @@ time timeupdate toggle transitionend +unhandledrejection unload url waiting diff --git a/components/malloc_size_of/Cargo.toml b/components/malloc_size_of/Cargo.toml index e982925e57a..04df21fd628 100644 --- a/components/malloc_size_of/Cargo.toml +++ b/components/malloc_size_of/Cargo.toml @@ -32,7 +32,7 @@ hashglobe = { path = "../hashglobe" } hyper = { version = "0.10", optional = true } hyper_serde = { version = "0.8", optional = true } keyboard-types = {version = "0.4.2-servo", features = ["serde"], optional = true} -mozjs = { version = "0.9.0", optional = true } +mozjs = { version = "0.9.3", optional = true } selectors = { path = "../selectors" } serde = { version = "1.0.27", optional = true } serde_bytes = { version = "0.10", optional = true } diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index ece8095f021..12cb7c6c667 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -68,7 +68,7 @@ metrics = {path = "../metrics"} mitochondria = "1.1.2" mime = "0.2.1" mime_guess = "1.8.0" -mozjs = "0.9.0" +mozjs = "0.9.3" msg = {path = "../msg"} net_traits = {path = "../net_traits"} num-traits = "0.2" diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 62eae2dedae..c38a5869d61 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -30,6 +30,7 @@ use ipc_channel::ipc::IpcSender; use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL}; use js::glue::{IsWrapper, UnwrapObject}; use js::jsapi::{CurrentGlobalOrNull, GetGlobalForObjectCrossCompartment}; +use js::jsapi::{Heap, HandleObject}; use js::jsapi::{JSAutoCompartment, JSContext}; use js::jsapi::JSObject; use js::panic::maybe_resume_unwind; @@ -135,6 +136,23 @@ pub struct GlobalScope { /// Vector storing references of all eventsources. event_source_tracker: DOMTracker, + + /// Storage for watching rejected promises waiting for some client to + /// consume their rejection. + /// Promises in this list have been rejected in the last turn of the + /// event loop without the rejection being handled. + /// Note that this can contain nullptrs in place of promises removed because + /// they're consumed before it'd be reported. + /// + /// + uncaught_rejections: DomRefCell>>>, + + /// Promises in this list have previously been reported as rejected + /// (because they were in the above list), but the rejection was handled + /// in the last turn of the event loop. + /// + /// + consumed_rejections: DomRefCell>>>, } impl GlobalScope { @@ -169,6 +187,8 @@ impl GlobalScope { microtask_queue, list_auto_close_worker: Default::default(), event_source_tracker: DOMTracker::new(), + uncaught_rejections: Default::default(), + consumed_rejections: Default::default(), } } @@ -230,6 +250,39 @@ impl GlobalScope { GlobalScope::from_object(obj) } + pub fn add_uncaught_rejection(&self, rejection: HandleObject) { + self.uncaught_rejections.borrow_mut().push(Heap::boxed(rejection.get())); + } + + pub fn remove_uncaught_rejection(&self, rejection: HandleObject) { + let mut uncaught_rejections = self.uncaught_rejections.borrow_mut(); + + if let Some(index) = uncaught_rejections.iter().position(|promise| *promise == Heap::boxed(rejection.get())) { + uncaught_rejections.remove(index); + } + } + + pub fn get_uncaught_rejections(&self) -> &DomRefCell>>> { + &self.uncaught_rejections + } + + pub fn add_consumed_rejection(&self, rejection: HandleObject) { + self.consumed_rejections.borrow_mut().push(Heap::boxed(rejection.get())); + } + + pub fn remove_consumed_rejection(&self, rejection: HandleObject) { + let mut consumed_rejections = self.consumed_rejections.borrow_mut(); + + if let Some(index) = consumed_rejections.iter().position(|promise| *promise == Heap::boxed(rejection.get())) { + consumed_rejections.remove(index); + } + } + + pub fn get_consumed_rejections(&self) -> &DomRefCell>>> { + &self.consumed_rejections + } + + #[allow(unsafe_code)] pub fn get_cx(&self) -> *mut JSContext { Runtime::get() } @@ -586,7 +639,10 @@ impl GlobalScope { /// Perform a microtask checkpoint. pub fn perform_a_microtask_checkpoint(&self) { self.microtask_queue - .checkpoint(|_| Some(DomRoot::from_ref(self))); + .checkpoint( + |_| Some(DomRoot::from_ref(self)), + vec![DomRoot::from_ref(self)] + ); } /// Enqueue a microtask for subsequent execution. diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index 3587a11a0ad..88b50d54f2f 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -428,6 +428,7 @@ pub mod processinginstruction; pub mod progressevent; pub mod promise; pub mod promisenativehandler; +pub mod promiserejectionevent; pub mod radionodelist; pub mod range; pub mod request; diff --git a/components/script/dom/promise.rs b/components/script/dom/promise.rs index 8112794f1c9..e7e40fb188b 100644 --- a/components/script/dom/promise.rs +++ b/components/script/dom/promise.rs @@ -93,7 +93,7 @@ impl Promise { } #[allow(unsafe_code, unrooted_must_root)] - unsafe fn new_with_js_promise(obj: HandleObject, cx: *mut JSContext) -> Rc { + pub unsafe fn new_with_js_promise(obj: HandleObject, cx: *mut JSContext) -> Rc { assert!(IsPromiseObject(obj)); let promise = Promise { reflector: Reflector::new(), diff --git a/components/script/dom/promiserejectionevent.rs b/components/script/dom/promiserejectionevent.rs new file mode 100644 index 00000000000..500e59643cd --- /dev/null +++ b/components/script/dom/promiserejectionevent.rs @@ -0,0 +1,114 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use dom::bindings::codegen::Bindings::EventBinding::EventMethods; +use dom::bindings::codegen::Bindings::PromiseRejectionEventBinding; +use dom::bindings::codegen::Bindings::PromiseRejectionEventBinding::PromiseRejectionEventMethods; +use dom::bindings::error::Fallible; +use dom::bindings::inheritance::Castable; +use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; +use dom::bindings::str::DOMString; +use dom::bindings::trace::RootedTraceableBox; +use dom::event::{Event, EventBubbles, EventCancelable}; +use dom::globalscope::GlobalScope; +use dom::promise::Promise; +use dom_struct::dom_struct; +use js::jsapi::{Heap, JSContext}; +use js::jsval::JSVal; +use js::rust::HandleValue; +use servo_atoms::Atom; +use std::rc::Rc; + +#[dom_struct] +pub struct PromiseRejectionEvent { + event: Event, + #[ignore_malloc_size_of = "Rc"] + promise: Rc, + #[ignore_malloc_size_of = "Defined in rust-mozjs"] + reason: Heap, +} + +impl PromiseRejectionEvent { + #[allow(unrooted_must_root)] + fn new_inherited(promise: Rc) -> Self { + PromiseRejectionEvent { + event: Event::new_inherited(), + promise, + reason: Heap::default() + } + } + + #[allow(unrooted_must_root)] + pub fn new( + global: &GlobalScope, + type_: Atom, + bubbles: EventBubbles, + cancelable: EventCancelable, + promise: Rc, + reason: HandleValue + ) -> DomRoot { + let ev = reflect_dom_object( + Box::new(PromiseRejectionEvent::new_inherited(promise)), + global, + PromiseRejectionEventBinding::Wrap + ); + + { + let event = ev.upcast::(); + event.init_event( + type_, + bool::from(bubbles), + bool::from(cancelable) + ); + + ev.reason.set(reason.get()); + } + ev + } + + #[allow(unrooted_must_root)] + pub fn Constructor( + global: &GlobalScope, + type_: DOMString, + init: RootedTraceableBox + ) -> Fallible> { + let reason = init.reason.handle(); + let promise = match init.promise.as_ref() { + Some(promise) => promise.clone(), + None => Promise::new(global) + }; + let bubbles = EventBubbles::from(init.parent.bubbles); + let cancelable = EventCancelable::from(init.parent.cancelable); + + let event = PromiseRejectionEvent::new( + global, + Atom::from(type_), + bubbles, + cancelable, + promise, + reason + ); + Ok(event) + } +} + +impl PromiseRejectionEventMethods for PromiseRejectionEvent { + #[allow(unrooted_must_root)] + // https://html.spec.whatwg.org/multipage/#dom-promiserejectionevent-promise + fn Promise(&self) -> Rc { + self.promise.clone() + } + + #[allow(unsafe_code)] + // https://html.spec.whatwg.org/multipage/#dom-promiserejectionevent-reason + unsafe fn Reason(&self, _cx: *mut JSContext) -> JSVal { + self.reason.get() + } + + // https://dom.spec.whatwg.org/#dom-event-istrusted + fn IsTrusted(&self) -> bool { + self.event.IsTrusted() + } +} diff --git a/components/script/dom/webidls/PromiseRejectionEvent.webidl b/components/script/dom/webidls/PromiseRejectionEvent.webidl new file mode 100644 index 00000000000..5e94062f2ff --- /dev/null +++ b/components/script/dom/webidls/PromiseRejectionEvent.webidl @@ -0,0 +1,16 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// https://html.spec.whatwg.org/multipage/#the-promiserejectionevent-interface + +[Constructor(DOMString type, optional PromiseRejectionEventInit eventInitDict), Exposed=(Window,Worker)] +interface PromiseRejectionEvent : Event { + readonly attribute Promise promise; + readonly attribute any reason; +}; + +dictionary PromiseRejectionEventInit : EventInit { + /* required */ Promise promise; + any reason; +}; diff --git a/components/script/microtask.rs b/components/script/microtask.rs index a4221dd92dc..1a707d8fc3f 100644 --- a/components/script/microtask.rs +++ b/components/script/microtask.rs @@ -15,6 +15,7 @@ use dom::htmlimageelement::ImageElementMicrotask; use dom::htmlmediaelement::MediaElementMicrotask; use dom::mutationobserver::MutationObserver; use msg::constellation_msg::PipelineId; +use script_runtime::notify_about_rejected_promises; use script_thread::ScriptThread; use std::cell::Cell; use std::mem; @@ -59,7 +60,7 @@ impl MicrotaskQueue { /// /// Perform a microtask checkpoint, executing all queued microtasks until the queue is empty. - pub fn checkpoint(&self, target_provider: F) + pub fn checkpoint(&self, target_provider: F, globalscopes: Vec>) where F: Fn(PipelineId) -> Option>, { @@ -70,7 +71,7 @@ impl MicrotaskQueue { // Step 1 self.performing_a_microtask_checkpoint.set(true); - // Steps 2-7 + // Steps 2 while !self.microtask_queue.borrow().is_empty() { rooted_vec!(let mut pending_queue); mem::swap(&mut *pending_queue, &mut *self.microtask_queue.borrow_mut()); @@ -98,9 +99,14 @@ impl MicrotaskQueue { } } - //TODO: Step 8 - notify about rejected promises + // Step 3 + for global in globalscopes.into_iter() { + notify_about_rejected_promises(&global); + } - // Step 9 + // TODO: Step 4 - Cleanup Indexed Database transactions. + + // Step 5 self.performing_a_microtask_checkpoint.set(false); } } diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 18138dcc2b0..276a913647a 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -8,24 +8,34 @@ use dom::bindings::codegen::Bindings::PromiseBinding::PromiseJobCallback; use dom::bindings::conversions::get_dom_class; use dom::bindings::conversions::private_from_object; +use dom::bindings::inheritance::Castable; use dom::bindings::refcounted::{LiveDOMReferences, trace_refcounted_objects}; +use dom::bindings::refcounted::{Trusted, TrustedPromise}; +use dom::bindings::reflector::DomObject; use dom::bindings::root::trace_roots; use dom::bindings::settings_stack; use dom::bindings::trace::{JSTraceable, trace_traceables}; use dom::bindings::utils::DOM_CALLBACKS; +use dom::event::{Event, EventBubbles, EventCancelable, EventStatus}; +use dom::eventtarget::EventTarget; use dom::globalscope::GlobalScope; +use dom::promise::Promise; +use dom::promiserejectionevent::PromiseRejectionEvent; use js::glue::CollectServoSizes; use js::glue::SetBuildId; -use js::jsapi::{DisableIncrementalGC, GCDescription, GCProgress, HandleObject}; +use js::jsapi::{BuildIdCharVector, DisableIncrementalGC, GCDescription, GCProgress}; +use js::jsapi::{Heap, HandleObject}; use js::jsapi::{JSContext, JSTracer, SetDOMCallbacks, SetGCSliceCallback}; use js::jsapi::{JSGCInvocationKind, JSGCStatus, JS_AddExtraGCRootsTracer, JS_SetGCCallback}; use js::jsapi::{JSGCMode, JSGCParamKey, JS_SetGCParameter, JS_SetGlobalJitCompilerOption}; use js::jsapi::{JSJitCompilerOption, JS_SetOffthreadIonCompilationEnabled, JS_SetParallelParsingEnabled}; -use js::jsapi::{JSObject, SetPreserveWrapperCallback, SetEnqueuePromiseJobCallback}; -use js::jsapi::{SetBuildIdOp, BuildIdCharVector}; +use js::jsapi::{JSObject, PromiseRejectionHandlingState, SetPreserveWrapperCallback}; +use js::jsapi::{SetBuildIdOp, SetEnqueuePromiseJobCallback, SetPromiseRejectionTrackerCallback}; use js::jsapi::ContextOptionsRef; use js::panic::wrap_panic; +use js::rust::Handle; use js::rust::Runtime as RustRuntime; +use js::rust::wrappers::{GetPromiseIsHandled, GetPromiseResult}; use malloc_size_of::MallocSizeOfOps; use microtask::{EnqueuedPromiseCallback, Microtask}; use msg::constellation_msg::PipelineId; @@ -43,7 +53,7 @@ use std::panic::AssertUnwindSafe; use std::ptr; use style::thread_state::{self, ThreadState}; use task::TaskBox; -use task_source::TaskSourceName; +use task_source::{TaskSource, TaskSourceName}; use time::{Tm, now}; /// Common messages used to control the event loops in both the script and the worker @@ -140,6 +150,115 @@ unsafe extern "C" fn enqueue_job( ) } +#[allow(unsafe_code)] +/// https://html.spec.whatwg.org/multipage/#the-hostpromiserejectiontracker-implementation +unsafe extern "C" fn promise_rejection_tracker( + cx: *mut JSContext, + promise: HandleObject, + state: PromiseRejectionHandlingState, + _data: *mut c_void +) { + // TODO: Step 2 - If script's muted errors is true, terminate these steps. + + // Step 3. + let global = GlobalScope::from_context(cx); + + wrap_panic(AssertUnwindSafe(|| { + match state { + // Step 4. + PromiseRejectionHandlingState::Unhandled => { + global.add_uncaught_rejection(promise); + }, + // Step 5. + PromiseRejectionHandlingState::Handled => { + // Step 5-1. + if global.get_uncaught_rejections().borrow().contains(&Heap::boxed(promise.get())) { + global.remove_uncaught_rejection(promise); + return; + } + + // Step 5-2. + if !global.get_consumed_rejections().borrow().contains(&Heap::boxed(promise.get())) { + global.add_consumed_rejection(promise); + return; + } + + // Step 5-3. + global.remove_consumed_rejection(promise); + + // TODO: Step 5-4 - Queue a task to fire `rejectionhandled` event + } + }; + }), ()); +} + +#[allow(unsafe_code, unrooted_must_root)] +/// https://html.spec.whatwg.org/multipage/#notify-about-rejected-promises +pub fn notify_about_rejected_promises(global: &GlobalScope) { + unsafe { + let cx = global.get_cx(); + + // Step 2. + if global.get_uncaught_rejections().borrow().len() > 0 { + // Step 1. + let uncaught_rejections: Vec = global.get_uncaught_rejections() + .borrow() + .iter() + .map(|promise| { + let promise = Promise::new_with_js_promise(Handle::from_raw(promise.handle()), cx); + + TrustedPromise::new(promise) + }) + .collect(); + + // Step 3. + global.get_uncaught_rejections().borrow_mut().clear(); + + let target = Trusted::new(global.upcast::()); + + // Step 4. + global.as_window().dom_manipulation_task_source().queue( + task!(unhandled_rejection_event: move || { + let target = target.root(); + let cx = target.global().get_cx(); + + for promise in uncaught_rejections { + let promise = promise.root(); + + // Step 4-1. + let promise_is_handled = GetPromiseIsHandled(promise.reflector().get_jsobject()); + if promise_is_handled { + continue; + } + + // Step 4-2. + rooted!(in(cx) let reason = GetPromiseResult(promise.reflector().get_jsobject())); + + let event = PromiseRejectionEvent::new( + &target.global(), + atom!("unhandledrejection"), + EventBubbles::DoesNotBubble, + EventCancelable::Cancelable, + promise, + reason.handle() + ); + + let event_status = event.upcast::().fire(&target); + + // Step 4-3. + if event_status == EventStatus::Canceled { + // TODO: The promise rejection is not handled; we need to add it back to the list. + } + + // TODO: Step 4-4 - If [[PromiseIsHandled]] is false, add promise to consumed_rejections + } + }), + global.upcast(), + ).unwrap(); + } + } +} + #[derive(JSTraceable)] pub struct Runtime(RustRuntime); @@ -182,6 +301,7 @@ pub unsafe fn new_rt_and_cx() -> Runtime { DisableIncrementalGC(cx); SetEnqueuePromiseJobCallback(cx, Some(enqueue_job), ptr::null_mut()); + SetPromiseRejectionTrackerCallback(cx, Some(promise_rejection_tracker), ptr::null_mut()); set_gc_zeal_options(cx); diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 931b0d230ef..0f756caccca 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -3200,8 +3200,16 @@ impl ScriptThread { } fn perform_a_microtask_checkpoint(&self) { + let globals = self.documents.borrow() + .iter() + .map(|(_id, document)| document.global()) + .collect(); + self.microtask_queue - .checkpoint(|id| self.documents.borrow().find_global(id)) + .checkpoint( + |id| self.documents.borrow().find_global(id), + globals + ) } } From 42903412c768f289558554419add125ce908e342 Mon Sep 17 00:00:00 2001 From: CYBAI Date: Sun, 10 Jun 2018 21:02:11 +0800 Subject: [PATCH 03/20] Make first argument of DOMManipulationTaskSource as a Box We don't have `window` for `workers`. So, if we use `global.as_window()` to get the DOMManipulationTaskSource, it will make worker panic. Instead, we should get the DOMManipulationTaskSource from each own thread. Ref: https://github.com/servo/servo/pull/20755#discussion_r193557746 --- components/script/dom/globalscope.rs | 11 ++++++++++ components/script/dom/workerglobalscope.rs | 5 +++++ components/script/script_runtime.rs | 2 +- components/script/script_thread.rs | 4 ++-- .../script/task_source/dom_manipulation.rs | 21 ++++++++++++------- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index c38a5869d61..a3e879326bc 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -56,6 +56,7 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use task::TaskCanceller; use task_source::TaskSourceName; +use task_source::dom_manipulation::DOMManipulationTaskSource; use task_source::file_reading::FileReadingTaskSource; use task_source::networking::NetworkingTaskSource; use task_source::performance_timeline::PerformanceTimelineTaskSource; @@ -680,6 +681,16 @@ impl GlobalScope { unreachable!(); } + pub fn dom_manipulation_task_source(&self) -> DOMManipulationTaskSource { + if let Some(window) = self.downcast::() { + return window.dom_manipulation_task_source(); + } + if let Some(worker) = self.downcast::() { + return worker.dom_manipulation_task_source(); + } + unreachable!(); + } + /// Channel to send messages to the file reading task source of /// this of this global scope. pub fn file_reading_task_source(&self) -> FileReadingTaskSource { diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index fa2d0a449cf..edcdb329af8 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -43,6 +43,7 @@ use std::rc::Rc; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use task::TaskCanceller; +use task_source::dom_manipulation::DOMManipulationTaskSource; use task_source::file_reading::FileReadingTaskSource; use task_source::networking::NetworkingTaskSource; use task_source::performance_timeline::PerformanceTimelineTaskSource; @@ -419,6 +420,10 @@ impl WorkerGlobalScope { } } + pub fn dom_manipulation_task_source(&self) -> DOMManipulationTaskSource { + DOMManipulationTaskSource(self.script_chan(), self.pipeline_id()) + } + pub fn file_reading_task_source(&self) -> FileReadingTaskSource { FileReadingTaskSource(self.script_chan(), self.pipeline_id()) } diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 276a913647a..b128e3e54b5 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -217,7 +217,7 @@ pub fn notify_about_rejected_promises(global: &GlobalScope) { let target = Trusted::new(global.upcast::()); // Step 4. - global.as_window().dom_manipulation_task_source().queue( + global.dom_manipulation_task_source().queue( task!(unhandled_rejection_event: move || { let target = target.root(); let cx = target.global().get_cx(); diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 0f756caccca..8795a65cd13 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -501,7 +501,7 @@ pub struct ScriptThread { /// events in the event queue. chan: MainThreadScriptChan, - dom_manipulation_task_sender: Sender, + dom_manipulation_task_sender: Box, media_element_task_sender: Sender, @@ -1020,7 +1020,7 @@ impl ScriptThread { task_queue, chan: MainThreadScriptChan(chan.clone()), - dom_manipulation_task_sender: chan.clone(), + dom_manipulation_task_sender: boxed_script_sender.clone(), media_element_task_sender: chan.clone(), user_interaction_task_sender: chan.clone(), networking_task_sender: boxed_script_sender.clone(), diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs index ad01f514e95..376927da742 100644 --- a/components/script/task_source/dom_manipulation.rs +++ b/components/script/task_source/dom_manipulation.rs @@ -8,17 +8,21 @@ use dom::event::{EventBubbles, EventCancelable, EventTask, SimpleEventTask}; use dom::eventtarget::EventTarget; use dom::window::Window; use msg::constellation_msg::PipelineId; -use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory}; -use script_thread::MainThreadScriptMsg; +use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; use servo_atoms::Atom; -use servo_channel::Sender; use std::fmt; use std::result::Result; use task::{TaskCanceller, TaskOnce}; use task_source::{TaskSource, TaskSourceName}; -#[derive(Clone, JSTraceable)] -pub struct DOMManipulationTaskSource(pub Sender, pub PipelineId); +#[derive(JSTraceable)] +pub struct DOMManipulationTaskSource(pub Box, pub PipelineId); + +impl Clone for DOMManipulationTaskSource { + fn clone(&self) -> DOMManipulationTaskSource { + DOMManipulationTaskSource(self.0.clone(), self.1.clone()) + } +} impl fmt::Debug for DOMManipulationTaskSource { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -33,13 +37,14 @@ impl TaskSource for DOMManipulationTaskSource { where T: TaskOnce + 'static, { - let msg = MainThreadScriptMsg::Common(CommonScriptMsg::Task( + let msg_task = CommonScriptMsg::Task( ScriptThreadEventCategory::ScriptEvent, Box::new(canceller.wrap_task(task)), Some(self.1), DOMManipulationTaskSource::NAME, - )); - self.0.send(msg).map_err(|_| ()) + ); + + self.0.send(msg_task).map_err(|_| ()) } } From 9039a5cc713e82824e86757dcf934f01b5c2ae2e Mon Sep 17 00:00:00 2001 From: CYBAI Date: Mon, 11 Jun 2018 00:18:31 +0800 Subject: [PATCH 04/20] Update test cases --- .../metadata/encoding/idlharness.any.js.ini | 10 ---- .../encoding/streams/backpressure.any.js.ini | 8 +-- .../streams/decode-attributes.any.js.ini | 8 +-- .../streams/decode-bad-chunks.any.js.ini | 4 +- .../streams/decode-ignore-bom.any.js.ini | 4 +- .../decode-incomplete-input.any.js.ini | 3 +- .../streams/decode-non-utf8.any.js.ini | 3 +- .../streams/decode-split-character.any.js.ini | 3 +- .../encoding/streams/decode-utf8.any.js.ini | 3 +- .../streams/encode-bad-chunks.any.js.ini | 4 +- .../encoding/streams/encode-utf8.any.js.ini | 4 +- .../readable-writable-properties.any.js.ini | 6 +-- .../fetch/api/abort/general.any.js.ini | 8 ++- .../basic/header-value-combining.any.js.ini | 3 +- .../basic/header-value-null-byte.any.js.ini | 3 +- .../api/basic/stream-safe-creation.any.js.ini | 3 +- tests/wpt/metadata/fetch/api/idl.any.js.ini | 1 - .../request/request-init-stream.any.js.ini | 3 +- .../response/response-from-stream.any.js.ini | 3 ++ .../idlharness.tentative.any.js.ini | 10 ++-- .../fetch.any.js.ini | 7 +-- .../metadata/hr-time/idlharness.any.js.ini | 9 ++-- .../tasks.window.js.ini | 3 -- .../queue-microtask-exceptions.any.js.ini | 9 ++-- .../queue-microtask.any.js.ini | 10 ++-- .../allow-crossorigin.html.ini | 4 -- ...ejection-events-attached-in-event.html.ini | 4 -- ...-rejection-events.dedicatedworker.html.ini | 33 ------------ .../promise-rejection-events.html.ini | 54 ------------------- .../idlharness.any.js.ini | 1 - .../wasm/webapi/contenttype.any.js.ini | 3 +- ...etnode-output-channel-count.https.html.ini | 3 +- .../metadata/websockets/basic-auth.any.js.ini | 12 ++--- .../importscripts_mime.tentative.any.js.ini | 8 +-- .../interface-objects/001.worker.js.ini | 3 -- 35 files changed, 71 insertions(+), 186 deletions(-) diff --git a/tests/wpt/metadata/encoding/idlharness.any.js.ini b/tests/wpt/metadata/encoding/idlharness.any.js.ini index 7eed0794ca3..eeec0c9a846 100644 --- a/tests/wpt/metadata/encoding/idlharness.any.js.ini +++ b/tests/wpt/metadata/encoding/idlharness.any.js.ini @@ -6,15 +6,6 @@ expected: FAIL -[idlharness.https.any.serviceworker.html] - expected: TIMEOUT - [Untitled] - expected: FAIL - - [idlharness] - expected: FAIL - - [idlharness.any.html] [Untitled] expected: FAIL @@ -152,7 +143,6 @@ [idlharness.any.serviceworker.html] - expected: TIMEOUT [idlharness] expected: FAIL diff --git a/tests/wpt/metadata/encoding/streams/backpressure.any.js.ini b/tests/wpt/metadata/encoding/streams/backpressure.any.js.ini index ae376965575..57e9dd17391 100644 --- a/tests/wpt/metadata/encoding/streams/backpressure.any.js.ini +++ b/tests/wpt/metadata/encoding/streams/backpressure.any.js.ini @@ -1,3 +1,7 @@ +[backpressure.any.serviceworker.html] + [backpressure] + expected: FAIL + [backpressure.any.sharedworker.html] [backpressure] expected: FAIL @@ -7,10 +11,6 @@ [backpressure] expected: FAIL - -[backpressure.any.serviceworker.html] - expected: TIMEOUT - [backpressure.any.worker.html] [backpressure] expected: FAIL diff --git a/tests/wpt/metadata/encoding/streams/decode-attributes.any.js.ini b/tests/wpt/metadata/encoding/streams/decode-attributes.any.js.ini index ca0beb4bacc..76a665146c5 100644 --- a/tests/wpt/metadata/encoding/streams/decode-attributes.any.js.ini +++ b/tests/wpt/metadata/encoding/streams/decode-attributes.any.js.ini @@ -1,3 +1,7 @@ +[decode-attributes.any.serviceworker.html] + [decode-attributes] + expected: FAIL + [decode-attributes.any.worker.html] [a throwing fatal member should cause the constructor to throw] expected: FAIL @@ -173,7 +177,3 @@ [encoding attribute should have correct value for 'ascii'] expected: FAIL - - -[decode-attributes.any.serviceworker.html] - expected: TIMEOUT diff --git a/tests/wpt/metadata/encoding/streams/decode-bad-chunks.any.js.ini b/tests/wpt/metadata/encoding/streams/decode-bad-chunks.any.js.ini index 072b3593998..061433df212 100644 --- a/tests/wpt/metadata/encoding/streams/decode-bad-chunks.any.js.ini +++ b/tests/wpt/metadata/encoding/streams/decode-bad-chunks.any.js.ini @@ -7,9 +7,9 @@ [decode-bad-chunks] expected: FAIL - [decode-bad-chunks.any.serviceworker.html] - expected: TIMEOUT + [decode-bad-chunks] + expected: FAIL [decode-bad-chunks.any.sharedworker.html] [decode-bad-chunks] diff --git a/tests/wpt/metadata/encoding/streams/decode-ignore-bom.any.js.ini b/tests/wpt/metadata/encoding/streams/decode-ignore-bom.any.js.ini index 259b7667bd8..48d11586b1e 100644 --- a/tests/wpt/metadata/encoding/streams/decode-ignore-bom.any.js.ini +++ b/tests/wpt/metadata/encoding/streams/decode-ignore-bom.any.js.ini @@ -35,9 +35,9 @@ [ignoreBOM should work for encoding utf-16le, split at character 0] expected: FAIL - [decode-ignore-bom.any.serviceworker.html] - expected: TIMEOUT + [decode-ignore-bom] + expected: FAIL [decode-ignore-bom.any.sharedworker.html] [decode-ignore-bom] diff --git a/tests/wpt/metadata/encoding/streams/decode-incomplete-input.any.js.ini b/tests/wpt/metadata/encoding/streams/decode-incomplete-input.any.js.ini index 6972b401446..aca41802b4d 100644 --- a/tests/wpt/metadata/encoding/streams/decode-incomplete-input.any.js.ini +++ b/tests/wpt/metadata/encoding/streams/decode-incomplete-input.any.js.ini @@ -1,5 +1,6 @@ [decode-incomplete-input.any.serviceworker.html] - expected: TIMEOUT + [decode-incomplete-input] + expected: FAIL [decode-incomplete-input.any.sharedworker.html] [decode-incomplete-input] diff --git a/tests/wpt/metadata/encoding/streams/decode-non-utf8.any.js.ini b/tests/wpt/metadata/encoding/streams/decode-non-utf8.any.js.ini index 6510f801f28..137cf1c54a2 100644 --- a/tests/wpt/metadata/encoding/streams/decode-non-utf8.any.js.ini +++ b/tests/wpt/metadata/encoding/streams/decode-non-utf8.any.js.ini @@ -68,4 +68,5 @@ [decode-non-utf8.any.serviceworker.html] - expected: TIMEOUT + [decode-non-utf8] + expected: FAIL diff --git a/tests/wpt/metadata/encoding/streams/decode-split-character.any.js.ini b/tests/wpt/metadata/encoding/streams/decode-split-character.any.js.ini index affec6b9557..4748271bcaf 100644 --- a/tests/wpt/metadata/encoding/streams/decode-split-character.any.js.ini +++ b/tests/wpt/metadata/encoding/streams/decode-split-character.any.js.ini @@ -1,5 +1,6 @@ [decode-split-character.any.serviceworker.html] - expected: TIMEOUT + [decode-split-character] + expected: FAIL [decode-split-character.any.sharedworker.html] [decode-split-character] diff --git a/tests/wpt/metadata/encoding/streams/decode-utf8.any.js.ini b/tests/wpt/metadata/encoding/streams/decode-utf8.any.js.ini index e0dbbd4d512..73f5ad9d0d5 100644 --- a/tests/wpt/metadata/encoding/streams/decode-utf8.any.js.ini +++ b/tests/wpt/metadata/encoding/streams/decode-utf8.any.js.ini @@ -1,5 +1,6 @@ [decode-utf8.any.serviceworker.html] - expected: TIMEOUT + [decode-utf8] + expected: FAIL [decode-utf8.any.sharedworker.html] [decode-utf8] diff --git a/tests/wpt/metadata/encoding/streams/encode-bad-chunks.any.js.ini b/tests/wpt/metadata/encoding/streams/encode-bad-chunks.any.js.ini index ddde7b046bc..436dec1a125 100644 --- a/tests/wpt/metadata/encoding/streams/encode-bad-chunks.any.js.ini +++ b/tests/wpt/metadata/encoding/streams/encode-bad-chunks.any.js.ini @@ -42,6 +42,6 @@ [encode-bad-chunks] expected: FAIL - [encode-bad-chunks.any.serviceworker.html] - expected: TIMEOUT + [encode-bad-chunks] + expected: FAIL diff --git a/tests/wpt/metadata/encoding/streams/encode-utf8.any.js.ini b/tests/wpt/metadata/encoding/streams/encode-utf8.any.js.ini index 1a887518165..dde8e15080f 100644 --- a/tests/wpt/metadata/encoding/streams/encode-utf8.any.js.ini +++ b/tests/wpt/metadata/encoding/streams/encode-utf8.any.js.ini @@ -120,6 +120,6 @@ [encode-utf8] expected: FAIL - [encode-utf8.any.serviceworker.html] - expected: TIMEOUT + [encode-utf8] + expected: FAIL diff --git a/tests/wpt/metadata/encoding/streams/readable-writable-properties.any.js.ini b/tests/wpt/metadata/encoding/streams/readable-writable-properties.any.js.ini index b4b8335f34f..2862a708a06 100644 --- a/tests/wpt/metadata/encoding/streams/readable-writable-properties.any.js.ini +++ b/tests/wpt/metadata/encoding/streams/readable-writable-properties.any.js.ini @@ -6,9 +6,6 @@ expected: FAIL -[readable-writable-properties.any.serviceworker.html] - expected: TIMEOUT - [readable-writable-properties.any.worker.html] [TextDecoderStream readable and writable properties must pass brand checks] expected: FAIL @@ -16,6 +13,9 @@ [TextEncoderStream readable and writable properties must pass brand checks] expected: FAIL +[readable-writable-properties.any.serviceworker.html] + [readable-writable-properties] + expected: FAIL [readable-writable-properties.any.sharedworker.html] [readable-writable-properties] diff --git a/tests/wpt/metadata/fetch/api/abort/general.any.js.ini b/tests/wpt/metadata/fetch/api/abort/general.any.js.ini index 0b0a6200e23..f7ffeaa41d2 100644 --- a/tests/wpt/metadata/fetch/api/abort/general.any.js.ini +++ b/tests/wpt/metadata/fetch/api/abort/general.any.js.ini @@ -203,6 +203,9 @@ [Clone aborts with original controller] expected: FAIL +[general.any.serviceworker.html] + [general] + expected: FAIL [general.https.any.serviceworker.html] expected: TIMEOUT @@ -221,8 +224,3 @@ expected: FAIL -[general.any.serviceworker.html] - expected: TIMEOUT - [general] - expected: FAIL - diff --git a/tests/wpt/metadata/fetch/api/basic/header-value-combining.any.js.ini b/tests/wpt/metadata/fetch/api/basic/header-value-combining.any.js.ini index 1c41d1fd534..716da35d14e 100644 --- a/tests/wpt/metadata/fetch/api/basic/header-value-combining.any.js.ini +++ b/tests/wpt/metadata/fetch/api/basic/header-value-combining.any.js.ini @@ -15,7 +15,8 @@ [header-value-combining.any.serviceworker.html] - expected: TIMEOUT + [header-value-combining] + expected: FAIL [header-value-combining.any.sharedworker.html] [header-value-combining] diff --git a/tests/wpt/metadata/fetch/api/basic/header-value-null-byte.any.js.ini b/tests/wpt/metadata/fetch/api/basic/header-value-null-byte.any.js.ini index 96389a8b64e..e065e3b8d06 100644 --- a/tests/wpt/metadata/fetch/api/basic/header-value-null-byte.any.js.ini +++ b/tests/wpt/metadata/fetch/api/basic/header-value-null-byte.any.js.ini @@ -8,4 +8,5 @@ [header-value-null-byte.any.worker.html] [header-value-null-byte.any.serviceworker.html] - expected: TIMEOUT + [header-value-null-byte] + expected: FAIL diff --git a/tests/wpt/metadata/fetch/api/basic/stream-safe-creation.any.js.ini b/tests/wpt/metadata/fetch/api/basic/stream-safe-creation.any.js.ini index 1aab3419c1c..45e02e88567 100644 --- a/tests/wpt/metadata/fetch/api/basic/stream-safe-creation.any.js.ini +++ b/tests/wpt/metadata/fetch/api/basic/stream-safe-creation.any.js.ini @@ -1,5 +1,6 @@ [stream-safe-creation.any.serviceworker.html] - expected: TIMEOUT + [stream-safe-creation] + expected: FAIL [stream-safe-creation.any.sharedworker.html] [stream-safe-creation] diff --git a/tests/wpt/metadata/fetch/api/idl.any.js.ini b/tests/wpt/metadata/fetch/api/idl.any.js.ini index e4069ebaffe..73f5bb7ec46 100644 --- a/tests/wpt/metadata/fetch/api/idl.any.js.ini +++ b/tests/wpt/metadata/fetch/api/idl.any.js.ini @@ -140,7 +140,6 @@ [idl.any.serviceworker.html] - expected: TIMEOUT [idl] expected: FAIL diff --git a/tests/wpt/metadata/fetch/api/request/request-init-stream.any.js.ini b/tests/wpt/metadata/fetch/api/request/request-init-stream.any.js.ini index 8bb9e65c259..433acff7b54 100644 --- a/tests/wpt/metadata/fetch/api/request/request-init-stream.any.js.ini +++ b/tests/wpt/metadata/fetch/api/request/request-init-stream.any.js.ini @@ -44,4 +44,5 @@ [request-init-stream.any.serviceworker.html] - expected: TIMEOUT + [request-init-stream] + expected: FAIL diff --git a/tests/wpt/metadata/fetch/api/response/response-from-stream.any.js.ini b/tests/wpt/metadata/fetch/api/response/response-from-stream.any.js.ini index ccf43c56945..d55a9df46a1 100644 --- a/tests/wpt/metadata/fetch/api/response/response-from-stream.any.js.ini +++ b/tests/wpt/metadata/fetch/api/response/response-from-stream.any.js.ini @@ -27,3 +27,6 @@ [Constructing a Response with a stream on which read() is called] expected: FAIL +[response-from-stream.any.serviceworker.html] + [response-from-stream] + expected: FAIL diff --git a/tests/wpt/metadata/fetch/cors-rfc1918/idlharness.tentative.any.js.ini b/tests/wpt/metadata/fetch/cors-rfc1918/idlharness.tentative.any.js.ini index 4b69e30a81a..7141075785f 100644 --- a/tests/wpt/metadata/fetch/cors-rfc1918/idlharness.tentative.any.js.ini +++ b/tests/wpt/metadata/fetch/cors-rfc1918/idlharness.tentative.any.js.ini @@ -19,6 +19,9 @@ [WorkerGlobalScope interface: self must inherit property "addressSpace" with the proper type] expected: FAIL +[idlharness.tentative.any.serviceworker.html] + [idlharness] + expected: FAIL [idlharness.tentative.https.any.serviceworker.html] expected: TIMEOUT @@ -26,10 +29,3 @@ [idlharness.tentative.any.sharedworker.html] [idlharness] expected: FAIL - - -[idlharness.tentative.any.serviceworker.html] - expected: TIMEOUT - [idlharness] - expected: FAIL - diff --git a/tests/wpt/metadata/fetch/cross-origin-resource-policy/fetch.any.js.ini b/tests/wpt/metadata/fetch/cross-origin-resource-policy/fetch.any.js.ini index 6e940d3b8a2..e0fd3817835 100644 --- a/tests/wpt/metadata/fetch/cross-origin-resource-policy/fetch.any.js.ini +++ b/tests/wpt/metadata/fetch/cross-origin-resource-policy/fetch.any.js.ini @@ -1,3 +1,7 @@ +[fetch.any.serviceworker.html] + [fetch] + expected: FAIL + [fetch.any.html] [fetch] expected: FAIL @@ -44,9 +48,6 @@ expected: FAIL -[fetch.any.serviceworker.html] - expected: TIMEOUT - [fetch.any.sharedworker.html] [fetch] expected: FAIL diff --git a/tests/wpt/metadata/hr-time/idlharness.any.js.ini b/tests/wpt/metadata/hr-time/idlharness.any.js.ini index a29d0a932a0..9f19d08947f 100644 --- a/tests/wpt/metadata/hr-time/idlharness.any.js.ini +++ b/tests/wpt/metadata/hr-time/idlharness.any.js.ini @@ -23,6 +23,9 @@ [Test default toJSON operation of Performance] expected: FAIL +[idlharness.any.serviceworker.html] + [idlharness] + expected: FAIL [idlharness.any.sharedworker.html] [idlharness] @@ -60,9 +63,3 @@ [Test default toJSON operation of Performance] expected: FAIL - -[idlharness.any.serviceworker.html] - expected: TIMEOUT - [idlharness] - expected: TIMEOUT - diff --git a/tests/wpt/metadata/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/tasks.window.js.ini b/tests/wpt/metadata/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/tasks.window.js.ini index bc2daf2d3d8..167bfceebf9 100644 --- a/tests/wpt/metadata/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/tasks.window.js.ini +++ b/tests/wpt/metadata/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/tasks.window.js.ini @@ -12,9 +12,6 @@ [document.open() and tasks (marquee start)] expected: TIMEOUT - [tasks without document.open() (Promise rejection)] - expected: TIMEOUT - [tasks without document.open() (marquee start)] expected: TIMEOUT diff --git a/tests/wpt/metadata/html/webappapis/microtask-queuing/queue-microtask-exceptions.any.js.ini b/tests/wpt/metadata/html/webappapis/microtask-queuing/queue-microtask-exceptions.any.js.ini index f93e06e9ad9..f1a0f0f5a60 100644 --- a/tests/wpt/metadata/html/webappapis/microtask-queuing/queue-microtask-exceptions.any.js.ini +++ b/tests/wpt/metadata/html/webappapis/microtask-queuing/queue-microtask-exceptions.any.js.ini @@ -2,6 +2,9 @@ [It rethrows exceptions] expected: FAIL +[queue-microtask-exceptions.any.serviceworker.html] + [queue-microtask-exceptions] + expected: FAIL [queue-microtask-exceptions.https.any.serviceworker.html] [queue-microtask-exceptions] @@ -17,9 +20,3 @@ [It rethrows exceptions] expected: FAIL - -[queue-microtask-exceptions.any.serviceworker.html] - expected: TIMEOUT - [queue-microtask-exceptions] - expected: FAIL - diff --git a/tests/wpt/metadata/html/webappapis/microtask-queuing/queue-microtask.any.js.ini b/tests/wpt/metadata/html/webappapis/microtask-queuing/queue-microtask.any.js.ini index 9c6de471eb4..85d783a2a93 100644 --- a/tests/wpt/metadata/html/webappapis/microtask-queuing/queue-microtask.any.js.ini +++ b/tests/wpt/metadata/html/webappapis/microtask-queuing/queue-microtask.any.js.ini @@ -14,6 +14,9 @@ [It interleaves with promises as expected] expected: FAIL +[queue-microtask.any.serviceworker.html] + [queue-microtask] + expected: FAIL [queue-microtask.any.sharedworker.html] [queue-microtask] @@ -41,10 +44,3 @@ [It interleaves with promises as expected] expected: FAIL - - -[queue-microtask.any.serviceworker.html] - expected: TIMEOUT - [queue-microtask] - expected: FAIL - diff --git a/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/allow-crossorigin.html.ini b/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/allow-crossorigin.html.ini index 0cbcb92c61c..9d0edf1f8e2 100644 --- a/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/allow-crossorigin.html.ini +++ b/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/allow-crossorigin.html.ini @@ -1,6 +1,2 @@ [allow-crossorigin.html] type: testharness - expected: TIMEOUT - [Promise rejection event should be received for the cross-origin CORS script] - expected: TIMEOUT - diff --git a/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events-attached-in-event.html.ini b/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events-attached-in-event.html.ini index badde757f4c..71bed1ea8ab 100644 --- a/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events-attached-in-event.html.ini +++ b/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events-attached-in-event.html.ini @@ -1,6 +1,2 @@ [promise-rejection-events-attached-in-event.html] type: testharness - expected: TIMEOUT - [Attaching a handler in unhandledrejection should not trigger rejectionhandled.] - expected: TIMEOUT - diff --git a/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.dedicatedworker.html.ini b/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.dedicatedworker.html.ini index bdcbf6afe9d..ebbc4b65399 100644 --- a/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.dedicatedworker.html.ini +++ b/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.dedicatedworker.html.ini @@ -1,39 +1,9 @@ [promise-rejection-events.dedicatedworker.html] type: testharness expected: TIMEOUT - [unhandledrejection: from Promise.reject] - expected: TIMEOUT - - [unhandledrejection: from a synchronous rejection in new Promise] - expected: TIMEOUT - [unhandledrejection: from a task-delayed rejection] expected: TIMEOUT - [unhandledrejection: from a setTimeout-delayed rejection] - expected: TIMEOUT - - [unhandledrejection: from a throw in a rejection handler chained off of Promise.reject] - expected: TIMEOUT - - [unhandledrejection: from a throw in a rejection handler chained off of a setTimeout-delayed rejection] - expected: TIMEOUT - - [unhandledrejection: from a throw in a rejection handler attached one microtask after a setTimeout-delayed rejection] - expected: TIMEOUT - - [unhandledrejection: from returning a Promise.reject-created rejection in a fulfillment handler] - expected: TIMEOUT - - [unhandledrejection: from a throw in a fulfillment handler] - expected: TIMEOUT - - [unhandledrejection: from returning a setTimeout-delayed rejection in a fulfillment handler] - expected: TIMEOUT - - [unhandledrejection: from Promise.reject, indirected through Promise.all] - expected: TIMEOUT - [no unhandledrejection/rejectionhandled: all inside a queued task, a rejection handler attached synchronously to a promise created from returning a Promise.reject-created promise in a fulfillment handler] expected: FAIL @@ -55,6 +25,3 @@ [delayed handling: a nested-postMessageTask after promise creation/rejection, plus many promise microtasks, is too late to attach a rejection handler] expected: FAIL - [mutationObserverMicrotask vs. postMessageTask ordering is not disturbed inside unhandledrejection events] - expected: TIMEOUT - diff --git a/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.html.ini b/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.html.ini index 5f066f23cc3..9ac915db2bb 100644 --- a/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.html.ini +++ b/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.html.ini @@ -1,60 +1,6 @@ [promise-rejection-events.html] type: testharness expected: TIMEOUT - [unhandledrejection: from Promise.reject] - expected: TIMEOUT - - [unhandledrejection: from a synchronous rejection in new Promise] - expected: TIMEOUT - - [unhandledrejection: from a task-delayed rejection] - expected: TIMEOUT - - [unhandledrejection: from a setTimeout-delayed rejection] - expected: TIMEOUT - - [unhandledrejection: from a throw in a rejection handler chained off of Promise.reject] - expected: TIMEOUT - - [unhandledrejection: from a throw in a rejection handler chained off of a setTimeout-delayed rejection] - expected: TIMEOUT - - [unhandledrejection: from a throw in a rejection handler attached one microtask after a setTimeout-delayed rejection] - expected: TIMEOUT - - [unhandledrejection: from returning a Promise.reject-created rejection in a fulfillment handler] - expected: TIMEOUT - - [unhandledrejection: from a throw in a fulfillment handler] - expected: TIMEOUT - - [unhandledrejection: from returning a setTimeout-delayed rejection in a fulfillment handler] - expected: TIMEOUT - - [unhandledrejection: from Promise.reject, indirected through Promise.all] - expected: TIMEOUT - - [delayed handling: a nested-task delay before attaching a handler causes unhandledrejection] - expected: TIMEOUT - - [delayed handling: a nested-postMessageTask after promise creation/rejection, plus promise microtasks, is too late to attach a rejection handler] - expected: TIMEOUT - - [delayed handling: a nested-postMessageTask before promise creation/rejection, plus many promise microtasks, is too late to attach a rejection handler] - expected: TIMEOUT - - [delayed handling: a nested-postMessageTask after promise creation/rejection, plus many promise microtasks, is too late to attach a rejection handler] - expected: TIMEOUT - - [mutationObserverMicrotask vs. postMessageTask ordering is not disturbed inside unhandledrejection events] - expected: TIMEOUT - - [postMessageTask ordering vs. the task queued for unhandled rejection notification (1)] - expected: TIMEOUT - - [postMessageTask ordering vs. the task queued for unhandled rejection notification (2)] - expected: TIMEOUT - [rejectionhandled is dispatched from a queued task, and not immediately] expected: TIMEOUT diff --git a/tests/wpt/metadata/performance-timeline/idlharness.any.js.ini b/tests/wpt/metadata/performance-timeline/idlharness.any.js.ini index 2c6ace5c9fa..803dbf7eeaf 100644 --- a/tests/wpt/metadata/performance-timeline/idlharness.any.js.ini +++ b/tests/wpt/metadata/performance-timeline/idlharness.any.js.ini @@ -51,7 +51,6 @@ [idlharness.any.serviceworker.html] - expected: TIMEOUT [idlharness] expected: FAIL diff --git a/tests/wpt/metadata/wasm/webapi/contenttype.any.js.ini b/tests/wpt/metadata/wasm/webapi/contenttype.any.js.ini index 004edb5b712..67bf56e690b 100644 --- a/tests/wpt/metadata/wasm/webapi/contenttype.any.js.ini +++ b/tests/wpt/metadata/wasm/webapi/contenttype.any.js.ini @@ -92,4 +92,5 @@ [contenttype.any.serviceworker.html] - expected: TIMEOUT + [contenttype] + expected: FAIL diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-output-channel-count.https.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-output-channel-count.https.html.ini index 6c40044b08b..d5a0839d5dd 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-output-channel-count.https.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-output-channel-count.https.html.ini @@ -1,2 +1,3 @@ [audioworkletnode-output-channel-count.https.html] - expected: TIMEOUT + [\n Test the construction of AudioWorkletNode with real-time context\n ] + expected: FAIL diff --git a/tests/wpt/metadata/websockets/basic-auth.any.js.ini b/tests/wpt/metadata/websockets/basic-auth.any.js.ini index 995ff26d703..82ab5c1ee6a 100644 --- a/tests/wpt/metadata/websockets/basic-auth.any.js.ini +++ b/tests/wpt/metadata/websockets/basic-auth.any.js.ini @@ -6,6 +6,12 @@ [basic-auth] expected: FAIL +[basic-auth.any.serviceworker.html] + [Untitled] + expected: FAIL + + [basic-auth] + expected: FAIL [basic-auth.any.sharedworker.html] [Untitled] @@ -24,9 +30,3 @@ [HTTP basic authentication should work with WebSockets] expected: FAIL - -[basic-auth.any.serviceworker.html] - expected: TIMEOUT - [basic-auth] - expected: FAIL - diff --git a/tests/wpt/metadata/workers/importscripts_mime.tentative.any.js.ini b/tests/wpt/metadata/workers/importscripts_mime.tentative.any.js.ini index c1bdb07d8e0..4b66d340d4d 100644 --- a/tests/wpt/metadata/workers/importscripts_mime.tentative.any.js.ini +++ b/tests/wpt/metadata/workers/importscripts_mime.tentative.any.js.ini @@ -1,3 +1,7 @@ +[importscripts_mime.tentative.any.serviceworker.html] + [importscripts_mime] + expected: FAIL + [importscripts_mime.tentative.any.sharedworker.html] [importscripts_mime] expected: FAIL @@ -39,7 +43,3 @@ [importScripts() requires scripty MIME types: text/plain is blocked.] expected: FAIL - - -[importscripts_mime.tentative.any.serviceworker.html] - expected: TIMEOUT diff --git a/tests/wpt/metadata/workers/semantics/interface-objects/001.worker.js.ini b/tests/wpt/metadata/workers/semantics/interface-objects/001.worker.js.ini index bf57cc0f245..d62e99a8ea8 100644 --- a/tests/wpt/metadata/workers/semantics/interface-objects/001.worker.js.ini +++ b/tests/wpt/metadata/workers/semantics/interface-objects/001.worker.js.ini @@ -18,9 +18,6 @@ [The Path2D interface object should be exposed.] expected: FAIL - [The PromiseRejectionEvent interface object should be exposed.] - expected: FAIL - [The BroadcastChannel interface object should be exposed.] expected: FAIL From f952d7ce0a1fcae485fa6728b9c3237f7e5f9e66 Mon Sep 17 00:00:00 2001 From: CYBAI Date: Sun, 24 Jun 2018 18:32:17 +0800 Subject: [PATCH 05/20] Clear consumed rejections and add FIXME comments --- components/script/script_runtime.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index b128e3e54b5..2ab4ef986f0 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -256,6 +256,13 @@ pub fn notify_about_rejected_promises(global: &GlobalScope) { global.upcast(), ).unwrap(); } + + if global.get_consumed_rejections().borrow().len() > 0 { + // FIXME(cybai): Implement `rejectionhandled` event instead of clearing the whole + // consumed rejections + // https://html.spec.whatwg.org/multipage/#the-hostpromiserejectiontracker-implementation + global.get_consumed_rejections().borrow_mut().clear(); + } } } From 0f249e1eb610ece32804562491c0908537ecefdb Mon Sep 17 00:00:00 2001 From: CYBAI Date: Sun, 26 Aug 2018 21:42:30 +0800 Subject: [PATCH 06/20] Add PromiseRejectionEvent interface to interface tests --- tests/wpt/mozilla/tests/mozilla/interfaces.html | 1 + tests/wpt/mozilla/tests/mozilla/interfaces.worker.js | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/wpt/mozilla/tests/mozilla/interfaces.html b/tests/wpt/mozilla/tests/mozilla/interfaces.html index 8bbde3b46a8..9d262c595c6 100644 --- a/tests/wpt/mozilla/tests/mozilla/interfaces.html +++ b/tests/wpt/mozilla/tests/mozilla/interfaces.html @@ -189,6 +189,7 @@ test_interfaces([ "PopStateEvent", "ProcessingInstruction", "ProgressEvent", + "PromiseRejectionEvent", "RadioNodeList", "Range", "Request", diff --git a/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js b/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js index 926ae2e1792..fbd6e92c097 100644 --- a/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js +++ b/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js @@ -40,6 +40,7 @@ test_interfaces([ "PerformanceObserverEntryList", "PerformancePaintTiming", "ProgressEvent", + "PromiseRejectionEvent", "Request", "Response", "TextDecoder", From 9036ce4f5cb32feca7e9ee6f9772e6f3fe136fdf Mon Sep 17 00:00:00 2001 From: CYBAI Date: Sun, 26 Aug 2018 23:02:41 +0800 Subject: [PATCH 07/20] Add config for disallow-crossorigin.html This should be removed when #13195 fixed. --- .../disallow-crossorigin.html.ini | 5 +++++ tests/wpt/mozilla/meta/MANIFEST.json | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/disallow-crossorigin.html.ini diff --git a/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/disallow-crossorigin.html.ini b/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/disallow-crossorigin.html.ini new file mode 100644 index 00000000000..4f6125d0275 --- /dev/null +++ b/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/disallow-crossorigin.html.ini @@ -0,0 +1,5 @@ +[disallow-crossorigin.html] + type: testharness + expected: ERROR + [Promise rejection event should be muted for cross-origin non-CORS script] + expected: FAIL diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 48be8bbb3bb..035b89be086 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -27038,7 +27038,7 @@ "testharness" ], "mozilla/interfaces.html": [ - "8bbde3b46a8e9d5ead6f9a2bf372d9647ad059be", + "9d262c595c6cbb624bc8acb9ef2ae26622154004", "testharness" ], "mozilla/interfaces.js": [ @@ -27046,7 +27046,7 @@ "support" ], "mozilla/interfaces.worker.js": [ - "926ae2e1792ead1e4635688c3f65b21e8efdcfb2", + "fbd6e92c097dea4f99924de219c9f6aa07a45282", "testharness" ], "mozilla/invalid-this.html": [ From d5de841bfaddf32b92c3bcdc95d891693abea653 Mon Sep 17 00:00:00 2001 From: CYBAI Date: Sat, 1 Sep 2018 21:04:17 +0800 Subject: [PATCH 08/20] Label as ERROR due to createImageBitmap not implemented yet This should be fixed after #20650 done. --- .../2dcontext/imagebitmap/createImageBitmap-transfer.html.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/wpt/metadata/2dcontext/imagebitmap/createImageBitmap-transfer.html.ini b/tests/wpt/metadata/2dcontext/imagebitmap/createImageBitmap-transfer.html.ini index 72da108c5d4..e923e869480 100644 --- a/tests/wpt/metadata/2dcontext/imagebitmap/createImageBitmap-transfer.html.ini +++ b/tests/wpt/metadata/2dcontext/imagebitmap/createImageBitmap-transfer.html.ini @@ -1,4 +1,6 @@ [createImageBitmap-transfer.html] + type: testharness + expected: ERROR [Transfer ImageBitmap created from an HTMLCanvasElement] expected: FAIL From f4dfbbd0c7df69bbc0ae075f9148d57c78869f7c Mon Sep 17 00:00:00 2001 From: CYBAI Date: Sat, 1 Sep 2018 21:22:01 +0800 Subject: [PATCH 09/20] Label as FAIL due to depending on MessageChannel This should be fixed after #16622 merged. --- .../promise-rejection-events.dedicatedworker.html.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.dedicatedworker.html.ini b/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.dedicatedworker.html.ini index ebbc4b65399..4c6bc6ea006 100644 --- a/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.dedicatedworker.html.ini +++ b/tests/wpt/metadata/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.dedicatedworker.html.ini @@ -1,8 +1,7 @@ [promise-rejection-events.dedicatedworker.html] type: testharness - expected: TIMEOUT [unhandledrejection: from a task-delayed rejection] - expected: TIMEOUT + expected: FAIL [no unhandledrejection/rejectionhandled: all inside a queued task, a rejection handler attached synchronously to a promise created from returning a Promise.reject-created promise in a fulfillment handler] expected: FAIL From 4e17c0205a819d9fbd748999e0d35d4ddcfa68e7 Mon Sep 17 00:00:00 2001 From: CYBAI Date: Sat, 1 Sep 2018 23:58:44 +0800 Subject: [PATCH 10/20] Label as ERROR due to setPosition not implemented yet --- .../the-pannernode-interface/panner-equalpower.html.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-pannernode-interface/panner-equalpower.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-pannernode-interface/panner-equalpower.html.ini index 0a532a498af..e699b2199ab 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-pannernode-interface/panner-equalpower.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-pannernode-interface/panner-equalpower.html.ini @@ -1,5 +1,5 @@ [panner-equalpower.html] - expected: TIMEOUT + expected: ERROR [X Number of impulses found is not equal to 100. Got 0.] expected: FAIL From 445c1d0706f2dc13697d5b04d3940ded9b2ae7ce Mon Sep 17 00:00:00 2001 From: CYBAI Date: Sat, 15 Sep 2018 15:15:10 +0800 Subject: [PATCH 11/20] Label as ERROR due to SharedWorker not implemented yet --- tests/wpt/metadata/workers/name-property.html.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/wpt/metadata/workers/name-property.html.ini b/tests/wpt/metadata/workers/name-property.html.ini index 89acbcb5c72..2a70cfcb1a3 100644 --- a/tests/wpt/metadata/workers/name-property.html.ini +++ b/tests/wpt/metadata/workers/name-property.html.ini @@ -1,6 +1,6 @@ [name-property.html] type: testharness - expected: TIMEOUT + expected: ERROR [Test the name property of shared and dedicated workers via the name constructor option] expected: FAIL From 0284afc51ae8d2c12b2b57727e028a113d211d5c Mon Sep 17 00:00:00 2001 From: CYBAI Date: Sun, 14 Oct 2018 15:03:06 +0800 Subject: [PATCH 12/20] Assert play promise rejected caused by pause() --- tests/wpt/metadata/MANIFEST.json | 6 ++--- .../event_pause_noautoplay.html | 18 +++++++------- .../media-elements/event_play_noautoplay.html | 24 +++++++++---------- .../paused_true_during_pause.html | 6 +++-- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 5931c483b21..a233c1fad82 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -612764,7 +612764,7 @@ "testharness" ], "html/semantics/embedded-content/media-elements/event_pause_noautoplay.html": [ - "55482348387de77def1c1be10d3dbe174fa3cb58", + "8b985a65fe372346370075e3e9e992548e9b8abb", "testharness" ], "html/semantics/embedded-content/media-elements/event_play.html": [ @@ -612772,7 +612772,7 @@ "testharness" ], "html/semantics/embedded-content/media-elements/event_play_noautoplay.html": [ - "67285a95abdca01fd7bc6dc95f4ad8c94b7f8536", + "94fcb837d04c0f82da1660d95465b53bc8a052a6", "testharness" ], "html/semantics/embedded-content/media-elements/event_playing.html": [ @@ -613172,7 +613172,7 @@ "testharness" ], "html/semantics/embedded-content/media-elements/paused_true_during_pause.html": [ - "6c4eb7c0c09fd2f048c96eff66d58b05ab3e4952", + "2a9335bd4e6026ff1c029fb140c3b146474e3523", "testharness" ], "html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-move-to-other-document.html": [ diff --git a/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/event_pause_noautoplay.html b/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/event_pause_noautoplay.html index 55482348387..8b985a65fe3 100644 --- a/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/event_pause_noautoplay.html +++ b/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/event_pause_noautoplay.html @@ -14,26 +14,28 @@
diff --git a/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/event_play_noautoplay.html b/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/event_play_noautoplay.html index 67285a95abd..94fcb837d04 100644 --- a/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/event_play_noautoplay.html +++ b/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/event_play_noautoplay.html @@ -14,26 +14,26 @@
diff --git a/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/paused_true_during_pause.html b/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/paused_true_during_pause.html index 6c4eb7c0c09..2a9335bd4e6 100644 --- a/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/paused_true_during_pause.html +++ b/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/paused_true_during_pause.html @@ -21,10 +21,11 @@ test(function() { t.step(function() { assert_true(a.paused); }); + t.done(); }, false); a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); - a.play(); + a.play().catch(() => {}); a.pause(); }, "audio events - paused property"); @@ -35,10 +36,11 @@ test(function() { t.step(function() { assert_true(v.paused); }); + t.done(); }, false); v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); - v.play(); + v.play().catch(() => {}); v.pause(); }, "video events - paused property"); From 46b9f61417a83c9c062aa14ca35d5a102a814e6f Mon Sep 17 00:00:00 2001 From: CYBAI Date: Sun, 14 Oct 2018 15:43:19 +0800 Subject: [PATCH 13/20] Catch the rejected promise to avoid harness error --- tests/wpt/metadata/MANIFEST.json | 4 ++-- .../resource-selection-invoke-set-src-networkState.html | 2 +- .../playing-the-media-resource/play-in-detached-document.html | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index a233c1fad82..35725042f1c 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -613072,7 +613072,7 @@ "testharness" ], "html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-networkState.html": [ - "e195dedb044e4040b5191538b753fe6d77bbefc1", + "ed86dbe0c570f272f03d1e956b62ac7132830898", "testharness" ], "html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-not-in-document.html": [ @@ -613192,7 +613192,7 @@ "testharness" ], "html/semantics/embedded-content/media-elements/playing-the-media-resource/play-in-detached-document.html": [ - "9c6fd5fabc3d48e7f5a7220dfc5684471bd4c992", + "8e9a7843b734f5e2296593f50daa76f98abacaad", "testharness" ], "html/semantics/embedded-content/media-elements/playing-the-media-resource/playbackRate.html": [ diff --git a/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-networkState.html b/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-networkState.html index e195dedb044..ed86dbe0c57 100644 --- a/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-networkState.html +++ b/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-set-src-networkState.html @@ -6,7 +6,7 @@