diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-10-03 04:48:13 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-03 04:48:13 -0500 |
commit | 522734de22ddbbc256cad94d1f07a8149e6e58fa (patch) | |
tree | 81a7626b2a6e304628d1832436bd66cfea8a565d | |
parent | c93eaca6a3563ea8472b2ac783e9a596528517b8 (diff) | |
parent | dd5c527689c3291e19720966af2165ab055d840f (diff) | |
download | servo-522734de22ddbbc256cad94d1f07a8149e6e58fa.tar.gz servo-522734de22ddbbc256cad94d1f07a8149e6e58fa.zip |
Auto merge of #13554 - nox:cleanup-global, r=<try>
Some cleanups related to globals
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 42 | ||||
-rw-r--r-- | components/script/dom/bindings/global.rs | 87 | ||||
-rw-r--r-- | components/script/dom/bluetooth.rs | 15 | ||||
-rw-r--r-- | components/script/dom/bluetoothremotegattcharacteristic.rs | 4 | ||||
-rw-r--r-- | components/script/dom/bluetoothremotegattserver.rs | 4 | ||||
-rw-r--r-- | components/script/dom/bluetoothremotegattservice.rs | 8 | ||||
-rw-r--r-- | components/script/dom/bluetoothuuid.rs | 95 | ||||
-rw-r--r-- | components/script/dom/dedicatedworkerglobalscope.rs | 66 | ||||
-rw-r--r-- | components/script/dom/htmlscriptelement.rs | 6 | ||||
-rw-r--r-- | components/script/dom/serviceworkerglobalscope.rs | 13 | ||||
-rw-r--r-- | components/script/dom/window.rs | 70 | ||||
-rw-r--r-- | components/script/dom/worker.rs | 2 | ||||
-rw-r--r-- | components/script/dom/workerglobalscope.rs | 57 | ||||
-rw-r--r-- | components/script/script_thread.rs | 5 | ||||
-rw-r--r-- | components/script/timers.rs | 7 | ||||
-rw-r--r-- | components/script/webdriver_handlers.rs | 8 | ||||
-rw-r--r-- | components/script_traits/lib.rs | 2 |
17 files changed, 218 insertions, 273 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index a7bdc6ce01d..7c6b2fe3718 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -5628,13 +5628,6 @@ class CGDescriptor(CGThing): return name cgThings = [] - if not descriptor.interface.isCallback() and not descriptor.interface.isNamespace(): - cgThings.append(CGGetProtoObjectMethod(descriptor)) - reexports.append('GetProtoObject') - if (descriptor.interface.hasInterfaceObject() and - descriptor.shouldHaveGetConstructorObjectMethod()): - cgThings.append(CGGetConstructorObjectMethod(descriptor)) - reexports.append('GetConstructorObject') unscopableNames = [] for m in descriptor.interface.members: @@ -5681,17 +5674,6 @@ class CGDescriptor(CGThing): cgThings.append(CGClassFinalizeHook(descriptor)) cgThings.append(CGClassTraceHook(descriptor)) - if descriptor.interface.hasInterfaceObject(): - if descriptor.interface.ctor(): - cgThings.append(CGClassConstructHook(descriptor)) - for ctor in descriptor.interface.namedConstructors: - cgThings.append(CGClassConstructHook(descriptor, ctor)) - if not descriptor.interface.isCallback(): - cgThings.append(CGInterfaceObjectJSClass(descriptor)) - - if not descriptor.interface.isCallback() and not descriptor.interface.isNamespace(): - cgThings.append(CGPrototypeJSClass(descriptor)) - # If there are no constant members, don't make a module for constants constMembers = [m for m in descriptor.interface.members if m.isConst()] if constMembers: @@ -5700,11 +5682,6 @@ class CGDescriptor(CGThing): public=True)) reexports.append(descriptor.name + 'Constants') - if descriptor.interface.hasInterfaceObject() and descriptor.register: - cgThings.append(CGDefineDOMInterfaceMethod(descriptor)) - reexports.append('DefineDOMInterface') - cgThings.append(CGConstructorEnabled(descriptor)) - if descriptor.proxy: cgThings.append(CGDefineProxyHandler(descriptor)) @@ -5766,6 +5743,25 @@ class CGDescriptor(CGThing): cgThings.append(CGWeakReferenceableTrait(descriptor)) cgThings.append(CGGeneric(str(properties))) + + if not descriptor.interface.isCallback() and not descriptor.interface.isNamespace(): + cgThings.append(CGGetProtoObjectMethod(descriptor)) + reexports.append('GetProtoObject') + cgThings.append(CGPrototypeJSClass(descriptor)) + if descriptor.interface.hasInterfaceObject(): + if descriptor.interface.ctor(): + cgThings.append(CGClassConstructHook(descriptor)) + for ctor in descriptor.interface.namedConstructors: + cgThings.append(CGClassConstructHook(descriptor, ctor)) + if not descriptor.interface.isCallback(): + cgThings.append(CGInterfaceObjectJSClass(descriptor)) + if descriptor.shouldHaveGetConstructorObjectMethod(): + cgThings.append(CGGetConstructorObjectMethod(descriptor)) + reexports.append('GetConstructorObject') + if descriptor.register: + cgThings.append(CGDefineDOMInterfaceMethod(descriptor)) + reexports.append('DefineDOMInterface') + cgThings.append(CGConstructorEnabled(descriptor)) cgThings.append(CGCreateInterfaceObjectsMethod(descriptor, properties, haveUnscopables)) cgThings = generate_imports(config, CGList(cgThings, '\n'), [descriptor]) diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs index 9b4125bdc6a..5d679cce2e9 100644 --- a/components/script/dom/bindings/global.rs +++ b/components/script/dom/bindings/global.rs @@ -10,25 +10,29 @@ use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId}; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::conversions::root_from_object; -use dom::bindings::error::ErrorInfo; +use dom::bindings::error::{ErrorInfo, report_pending_exception}; use dom::bindings::js::Root; use dom::bindings::reflector::{Reflectable, Reflector}; use dom::console::TimerSet; -use dom::window::{self, ScriptHelpers}; +use dom::window; use dom::workerglobalscope::WorkerGlobalScope; 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::{JSContext, JSObject, JS_GetClass, MutableHandleValue}; -use js::jsapi::HandleValue; +use js::jsapi::{CurrentGlobalOrNull, Evaluate2, GetGlobalForObjectCrossCompartment}; +use js::jsapi::{HandleValue, JS_GetClass, JSAutoCompartment, JSContext}; +use js::jsapi::{JSObject, MutableHandleValue}; +use js::rust::CompileOptionsWrapper; +use libc; use msg::constellation_msg::PipelineId; use net_traits::{CoreResourceThread, IpcSend, ResourceThreads}; use profile_traits::{mem, time}; -use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, EnqueuedPromiseCallback}; +use script_runtime::{CommonScriptMsg, EnqueuedPromiseCallback, ScriptChan}; +use script_runtime::{ScriptPort, maybe_take_panic_result}; use script_thread::{MainThreadScriptChan, RunnableWrapper, ScriptThread}; use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEventRequest}; -use task_source::dom_manipulation::DOMManipulationTaskSource; +use std::ffi::CString; +use std::panic; use task_source::file_reading::FileReadingTaskSource; use timers::{OneshotTimerCallback, OneshotTimerHandle}; use url::Url; @@ -181,15 +185,6 @@ impl<'a> GlobalRef<'a> { } } - /// `TaskSource` used to queue DOM manipulation messages to the event loop of this global's - /// thread. - pub fn dom_manipulation_task_source(&self) -> DOMManipulationTaskSource { - match *self { - GlobalRef::Window(ref window) => window.dom_manipulation_task_source(), - GlobalRef::Worker(_) => unimplemented!(), - } - } - /// `ScriptChan` used to send messages to the event loop of this global's /// thread. pub fn networking_task_source(&self) -> Box<ScriptChan + Send> { @@ -201,15 +196,6 @@ impl<'a> GlobalRef<'a> { /// `ScriptChan` used to send messages to the event loop of this global's /// thread. - pub fn history_traversal_task_source(&self) -> Box<ScriptChan + Send> { - match *self { - GlobalRef::Window(ref window) => window.history_traversal_task_source(), - GlobalRef::Worker(ref worker) => worker.script_chan(), - } - } - - /// `ScriptChan` used to send messages to the event loop of this global's - /// thread. pub fn file_reading_task_source(&self) -> FileReadingTaskSource { match *self { GlobalRef::Window(ref window) => window.file_reading_task_source(), @@ -236,12 +222,51 @@ impl<'a> GlobalRef<'a> { } } - /// Evaluate the JS messages on the `RootedValue` of this global - pub fn evaluate_js_on_global_with_result(&self, code: &str, rval: MutableHandleValue) { - match *self { - GlobalRef::Window(window) => window.evaluate_js_on_global_with_result(code, rval), - GlobalRef::Worker(worker) => worker.evaluate_js_on_global_with_result(code, rval), - } + /// Evaluate JS code on this global. + pub fn evaluate_js_on_global_with_result( + &self, code: &str, rval: MutableHandleValue) { + self.evaluate_script_on_global_with_result(code, "", rval) + } + + /// Evaluate a JS script on this global. + #[allow(unsafe_code)] + pub fn evaluate_script_on_global_with_result( + &self, code: &str, filename: &str, rval: MutableHandleValue) { + let metadata = time::TimerMetadata { + url: if filename.is_empty() { + self.get_url().as_str().into() + } else { + filename.into() + }, + iframe: time::TimerMetadataFrameType::RootWindow, + incremental: time::TimerMetadataReflowType::FirstReflow, + }; + time::profile( + time::ProfilerCategory::ScriptEvaluate, + Some(metadata), + self.time_profiler_chan().clone(), + || { + let cx = self.get_cx(); + let globalhandle = self.reflector().get_jsobject(); + let code: Vec<u16> = code.encode_utf16().collect(); + let filename = CString::new(filename).unwrap(); + + let _ac = JSAutoCompartment::new(cx, globalhandle.get()); + let options = CompileOptionsWrapper::new(cx, filename.as_ptr(), 1); + unsafe { + if !Evaluate2(cx, options.ptr, code.as_ptr(), + code.len() as libc::size_t, + rval) { + debug!("error evaluating JS string"); + report_pending_exception(cx, true); + } + } + + if let Some(error) = maybe_take_panic_result() { + panic::resume_unwind(error); + } + } + ) } /// Set the `bool` value to indicate whether developer tools has requested diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs index eecaf6489be..42ad4c2730a 100644 --- a/components/script/dom/bluetooth.rs +++ b/components/script/dom/bluetooth.rs @@ -88,7 +88,7 @@ impl Bluetooth { // TODO: Step 1: Triggered by user activation. // Step 2. - let option = try!(convert_request_device_options(self.global().r(), filters, optional_services)); + let option = try!(convert_request_device_options(filters, optional_services)); // TODO: Step 3-5: Implement the permission API. @@ -123,8 +123,7 @@ impl Bluetooth { } // https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices -fn convert_request_device_options(global: GlobalRef, - filters: &Option<Vec<BluetoothRequestDeviceFilter>>, +fn convert_request_device_options(filters: &Option<Vec<BluetoothRequestDeviceFilter>>, optional_services: &Option<Vec<BluetoothServiceUUID>>) -> Fallible<RequestDeviceoptions> { // Step 2.2: There is no requiredServiceUUIDS, we scan for all devices. @@ -141,7 +140,7 @@ fn convert_request_device_options(global: GlobalRef, // Step 2.4. for filter in filters { // Step 2.4.8. - uuid_filters.push(try!(canonicalize_filter(&filter, global))); + uuid_filters.push(try!(canonicalize_filter(&filter))); } } @@ -149,7 +148,7 @@ fn convert_request_device_options(global: GlobalRef, if let &Some(ref opt_services) = optional_services { for opt_service in opt_services { // Step 2.5 - 2.6. - let uuid = try!(BluetoothUUID::GetService(global, opt_service.clone())).to_string(); + let uuid = try!(BluetoothUUID::service(opt_service.clone())).to_string(); // Step 2.7. // Note: What we are doing here is adding the not blacklisted UUIDs to the result vector, @@ -165,7 +164,7 @@ fn convert_request_device_options(global: GlobalRef, } // https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices -fn canonicalize_filter(filter: &BluetoothRequestDeviceFilter, global: GlobalRef) -> Fallible<BluetoothScanfilter> { +fn canonicalize_filter(filter: &BluetoothRequestDeviceFilter) -> Fallible<BluetoothScanfilter> { // Step 2.4.1. if filter.services.is_none() && filter.name.is_none() && @@ -190,7 +189,7 @@ fn canonicalize_filter(filter: &BluetoothRequestDeviceFilter, global: GlobalRef) for service in services { // Step 2.4.3.2 - 2.4.3.3. - let uuid = try!(BluetoothUUID::GetService(global, service.clone())).to_string(); + let uuid = try!(BluetoothUUID::service(service.clone())).to_string(); // Step 2.4.3.4. if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { @@ -251,7 +250,7 @@ fn canonicalize_filter(filter: &BluetoothRequestDeviceFilter, global: GlobalRef) let service_data_uuid = match filter.serviceDataUUID { Some(ref service_data_uuid) => { // Step 2.4.7.1 - 2.4.7.2. - let uuid = try!(BluetoothUUID::GetService(global, service_data_uuid.clone())).to_string(); + let uuid = try!(BluetoothUUID::service(service_data_uuid.clone())).to_string(); // Step 2.4.7.3. if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs index 633b0b060e2..6b7ba1dcfad 100644 --- a/components/script/dom/bluetoothremotegattcharacteristic.rs +++ b/components/script/dom/bluetoothremotegattcharacteristic.rs @@ -85,7 +85,7 @@ impl BluetoothRemoteGATTCharacteristic { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-getdescriptor fn get_descriptor(&self, descriptor: BluetoothDescriptorUUID) -> Fallible<Root<BluetoothRemoteGATTDescriptor>> { - let uuid = try!(BluetoothUUID::GetDescriptor(self.global().r(), descriptor)).to_string(); + let uuid = try!(BluetoothUUID::descriptor(descriptor)).to_string(); if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { return Err(Security) } @@ -112,7 +112,7 @@ impl BluetoothRemoteGATTCharacteristic { -> Fallible<Vec<Root<BluetoothRemoteGATTDescriptor>>> { let mut uuid: Option<String> = None; if let Some(d) = descriptor { - uuid = Some(try!(BluetoothUUID::GetDescriptor(self.global().r(), d)).to_string()); + uuid = Some(try!(BluetoothUUID::descriptor(d)).to_string()); if let Some(ref uuid) = uuid { if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { return Err(Security) diff --git a/components/script/dom/bluetoothremotegattserver.rs b/components/script/dom/bluetoothremotegattserver.rs index c9fa5477f3f..3439ba53350 100644 --- a/components/script/dom/bluetoothremotegattserver.rs +++ b/components/script/dom/bluetoothremotegattserver.rs @@ -70,7 +70,7 @@ impl BluetoothRemoteGATTServer { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-getprimaryservice fn get_primary_service(&self, service: BluetoothServiceUUID) -> Fallible<Root<BluetoothRemoteGATTService>> { - let uuid = try!(BluetoothUUID::GetService(self.global().r(), service)).to_string(); + let uuid = try!(BluetoothUUID::service(service)).to_string(); if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { return Err(Security) } @@ -98,7 +98,7 @@ impl BluetoothRemoteGATTServer { -> Fallible<Vec<Root<BluetoothRemoteGATTService>>> { let mut uuid: Option<String> = None; if let Some(s) = service { - uuid = Some(try!(BluetoothUUID::GetService(self.global().r(), s)).to_string()); + uuid = Some(try!(BluetoothUUID::service(s)).to_string()); if let Some(ref uuid) = uuid { if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { return Err(Security) diff --git a/components/script/dom/bluetoothremotegattservice.rs b/components/script/dom/bluetoothremotegattservice.rs index 709de16cf5f..3ece2507cd3 100644 --- a/components/script/dom/bluetoothremotegattservice.rs +++ b/components/script/dom/bluetoothremotegattservice.rs @@ -74,7 +74,7 @@ impl BluetoothRemoteGATTService { fn get_characteristic(&self, characteristic: BluetoothCharacteristicUUID) -> Fallible<Root<BluetoothRemoteGATTCharacteristic>> { - let uuid = try!(BluetoothUUID::GetCharacteristic(self.global().r(), characteristic)).to_string(); + let uuid = try!(BluetoothUUID::characteristic(characteristic)).to_string(); if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { return Err(Security) } @@ -112,7 +112,7 @@ impl BluetoothRemoteGATTService { -> Fallible<Vec<Root<BluetoothRemoteGATTCharacteristic>>> { let mut uuid: Option<String> = None; if let Some(c) = characteristic { - uuid = Some(try!(BluetoothUUID::GetCharacteristic(self.global().r(), c)).to_string()); + uuid = Some(try!(BluetoothUUID::characteristic(c)).to_string()); if let Some(ref uuid) = uuid { if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { return Err(Security) @@ -155,7 +155,7 @@ impl BluetoothRemoteGATTService { fn get_included_service(&self, service: BluetoothServiceUUID) -> Fallible<Root<BluetoothRemoteGATTService>> { - let uuid = try!(BluetoothUUID::GetService(self.global().r(), service)).to_string(); + let uuid = try!(BluetoothUUID::service(service)).to_string(); if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { return Err(Security) } @@ -185,7 +185,7 @@ impl BluetoothRemoteGATTService { -> Fallible<Vec<Root<BluetoothRemoteGATTService>>> { let mut uuid: Option<String> = None; if let Some(s) = service { - uuid = Some(try!(BluetoothUUID::GetService(self.global().r(), s)).to_string()); + uuid = Some(try!(BluetoothUUID::service(s)).to_string()); if let Some(ref uuid) = uuid { if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { return Err(Security) diff --git a/components/script/dom/bluetoothuuid.rs b/components/script/dom/bluetoothuuid.rs index dafda71a12b..e9669cc8acb 100644 --- a/components/script/dom/bluetoothuuid.rs +++ b/components/script/dom/bluetoothuuid.rs @@ -272,60 +272,36 @@ const VALID_UUID_REGEX: &'static str = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0- impl BluetoothUUID { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-canonicaluuid pub fn CanonicalUUID(_: GlobalRef, alias: u32) -> UUID { - DOMString::from(format!("{:08x}", &alias) + BASE_UUID) + canonical_uuid(alias) } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getservice - pub fn GetService(globalref: GlobalRef, name: BluetoothServiceUUID) -> Fallible<UUID> { - BluetoothUUID::resolve_uuid_name(globalref, - name, - BLUETOOTH_ASSIGNED_SERVICES, - DOMString::from(SERVICE_PREFIX)) + pub fn GetService(_: GlobalRef, name: BluetoothServiceUUID) -> Fallible<UUID> { + Self::service(name) } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getcharacteristic - pub fn GetCharacteristic(globalref: GlobalRef, name: BluetoothCharacteristicUUID) -> Fallible<UUID> { - BluetoothUUID::resolve_uuid_name(globalref, - name, - BLUETOOTH_ASSIGNED_CHARCTERISTICS, - DOMString::from(CHARACTERISTIC_PREFIX)) + pub fn GetCharacteristic(_: GlobalRef, name: BluetoothCharacteristicUUID) -> Fallible<UUID> { + Self::characteristic(name) } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getdescriptor - pub fn GetDescriptor(globalref: GlobalRef, name: BluetoothDescriptorUUID) -> Fallible<UUID> { - BluetoothUUID::resolve_uuid_name(globalref, - name, - BLUETOOTH_ASSIGNED_DESCRIPTORS, - DOMString::from(DESCRIPTOR_PREFIX)) + pub fn GetDescriptor(_: GlobalRef, name: BluetoothDescriptorUUID) -> Fallible<UUID> { + Self::descriptor(name) } +} - // https://webbluetoothcg.github.io/web-bluetooth/#resolveuuidname - pub fn resolve_uuid_name(globalref: GlobalRef, - name: StringOrUnsignedLong, - assigned_numbers_table: &'static [(&'static str, u32)], - prefix: DOMString) - -> Fallible<DOMString> { - match name { - // Step 1 - StringOrUnsignedLong::UnsignedLong(unsigned32) => { - Ok(BluetoothUUID::CanonicalUUID(globalref, unsigned32)) - }, - StringOrUnsignedLong::String(dstring) => { - // Step 2 - let regex = Regex::new(VALID_UUID_REGEX).unwrap(); - if regex.is_match(&*dstring) { - Ok(dstring) - } else { - // Step 3 - let concatenated = format!("{}.{}", prefix, dstring); - let is_in_table = assigned_numbers_table.iter().find(|p| p.0 == concatenated); - match is_in_table { - Some(&(_, alias)) => Ok(BluetoothUUID::CanonicalUUID(globalref, alias)), - None => Err(Syntax), - } - } - }, - } +impl BluetoothUUID { + pub fn service(name: BluetoothServiceUUID) -> Fallible<UUID> { + resolve_uuid_name(name, BLUETOOTH_ASSIGNED_SERVICES, SERVICE_PREFIX) + } + + pub fn characteristic(name: BluetoothServiceUUID) -> Fallible<UUID> { + resolve_uuid_name(name, BLUETOOTH_ASSIGNED_CHARCTERISTICS, CHARACTERISTIC_PREFIX) + } + + pub fn descriptor(name: BluetoothDescriptorUUID) -> Fallible<UUID> { + resolve_uuid_name(name, BLUETOOTH_ASSIGNED_DESCRIPTORS, DESCRIPTOR_PREFIX) } } @@ -337,3 +313,36 @@ impl Clone for StringOrUnsignedLong { } } } + +fn canonical_uuid(alias: u32) -> UUID { + UUID::from(format!("{:08x}", &alias) + BASE_UUID) +} + +// https://webbluetoothcg.github.io/web-bluetooth/#resolveuuidname +fn resolve_uuid_name( + name: StringOrUnsignedLong, + assigned_numbers_table: &'static [(&'static str, u32)], + prefix: &str) + -> Fallible<DOMString> { + match name { + // Step 1 + StringOrUnsignedLong::UnsignedLong(unsigned32) => { + Ok(canonical_uuid(unsigned32)) + }, + StringOrUnsignedLong::String(dstring) => { + // Step 2 + let regex = Regex::new(VALID_UUID_REGEX).unwrap(); + if regex.is_match(&*dstring) { + Ok(dstring) + } else { + // Step 3 + let concatenated = format!("{}.{}", prefix, dstring); + let is_in_table = assigned_numbers_table.iter().find(|p| p.0 == concatenated); + match is_in_table { + Some(&(_, alias)) => Ok(canonical_uuid(alias)), + None => Err(Syntax), + } + } + }, + } +} diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index c425c38b86b..49a46b88575 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -17,10 +17,6 @@ use dom::bindings::js::{Root, RootCollection}; use dom::bindings::reflector::Reflectable; use dom::bindings::str::DOMString; use dom::bindings::structuredclone::StructuredCloneData; -use dom::errorevent::ErrorEvent; -use dom::event::{Event, EventBubbles, EventCancelable}; -use dom::eventdispatcher::EventStatus; -use dom::eventtarget::EventTarget; use dom::messageevent::MessageEvent; use dom::worker::{TrustedWorkerAddress, WorkerErrorHandler, WorkerMessageHandler}; use dom::workerglobalscope::WorkerGlobalScope; @@ -36,7 +32,6 @@ use rand::random; use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, StackRootTLS, get_reports, new_rt_and_cx}; use script_runtime::ScriptThreadEventCategory::WorkerEvent; use script_traits::{TimerEvent, TimerSource, WorkerGlobalScopeInit, WorkerScriptLoadOrigin}; -use std::cell::Cell; use std::mem::replace; use std::sync::{Arc, Mutex}; use std::sync::atomic::AtomicBool; @@ -81,7 +76,6 @@ enum MixedMessage { #[dom_struct] pub struct DedicatedWorkerGlobalScope { workerglobalscope: WorkerGlobalScope, - id: PipelineId, #[ignore_heap_size_of = "Defined in std"] receiver: Receiver<(TrustedWorkerAddress, WorkerScriptMsg)>, #[ignore_heap_size_of = "Defined in std"] @@ -93,14 +87,11 @@ pub struct DedicatedWorkerGlobalScope { #[ignore_heap_size_of = "Can't measure trait objects"] /// Sender to the parent thread. parent_sender: Box<ScriptChan + Send>, - /// https://html.spec.whatwg.org/multipage/#in-error-reporting-mode - in_error_reporting_mode: Cell<bool> } impl DedicatedWorkerGlobalScope { fn new_inherited(init: WorkerGlobalScopeInit, worker_url: Url, - id: PipelineId, from_devtools_receiver: Receiver<DevtoolScriptControlMsg>, runtime: Runtime, parent_sender: Box<ScriptChan + Send>, @@ -117,19 +108,16 @@ impl DedicatedWorkerGlobalScope { from_devtools_receiver, timer_event_chan, Some(closing)), - id: id, receiver: receiver, own_sender: own_sender, timer_event_port: timer_event_port, parent_sender: parent_sender, worker: DOMRefCell::new(None), - in_error_reporting_mode: Cell::new(false), } } pub fn new(init: WorkerGlobalScopeInit, worker_url: Url, - id: PipelineId, from_devtools_receiver: Receiver<DevtoolScriptControlMsg>, runtime: Runtime, parent_sender: Box<ScriptChan + Send>, @@ -142,7 +130,6 @@ impl DedicatedWorkerGlobalScope { let cx = runtime.cx(); let scope = box DedicatedWorkerGlobalScope::new_inherited(init, worker_url, - id, from_devtools_receiver, runtime, parent_sender, @@ -157,7 +144,6 @@ impl DedicatedWorkerGlobalScope { #[allow(unsafe_code)] pub fn run_worker_scope(init: WorkerGlobalScopeInit, worker_url: Url, - id: PipelineId, from_devtools_receiver: IpcReceiver<DevtoolScriptControlMsg>, worker_rt_for_mainthread: Arc<Mutex<Option<SharedRt>>>, worker: TrustedWorkerAddress, @@ -170,7 +156,7 @@ impl DedicatedWorkerGlobalScope { let name = format!("WebWorker for {}", serialized_worker_url); spawn_named(name, move || { thread_state::initialize(thread_state::SCRIPT | thread_state::IN_WORKER); - PipelineId::install(id); + PipelineId::install(init.pipeline_id); let roots = RootCollection::new(); let _stack_roots_tls = StackRootTLS::new(&roots); @@ -204,7 +190,7 @@ impl DedicatedWorkerGlobalScope { }); let global = DedicatedWorkerGlobalScope::new( - init, url, id, devtools_mpsc_port, runtime, + init, url, devtools_mpsc_port, runtime, parent_sender.clone(), own_sender, receiver, timer_ipc_chan, timer_rx, closing); // FIXME(njn): workers currently don't have a unique ID suitable for using in reporter @@ -244,10 +230,6 @@ impl DedicatedWorkerGlobalScope { } } - pub fn pipeline_id(&self) -> PipelineId { - self.id - } - pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) { let (tx, rx) = channel(); let chan = box SendableWorkerScriptChan { @@ -348,43 +330,13 @@ impl DedicatedWorkerGlobalScope { } } - /// https://html.spec.whatwg.org/multipage/#report-the-error - pub fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue) { - // Step 1. - if self.in_error_reporting_mode.get() { - return; - } - - // Step 2. - self.in_error_reporting_mode.set(true); - - // Steps 3-12. - // FIXME(#13195): muted errors. - let event = ErrorEvent::new(GlobalRef::Worker(self.upcast()), - atom!("error"), - EventBubbles::DoesNotBubble, - EventCancelable::Cancelable, - error_info.message.as_str().into(), - error_info.filename.as_str().into(), - error_info.lineno, - error_info.column, - value); - - // Step 13. - let event_status = event.upcast::<Event>().fire(self.upcast::<EventTarget>()); - - // Step 15 - if event_status == EventStatus::NotCanceled { - let worker = self.worker.borrow().as_ref().unwrap().clone(); - // TODO: Should use the DOM manipulation task source. - self.parent_sender - .send(CommonScriptMsg::RunnableMsg(WorkerEvent, - box WorkerErrorHandler::new(worker, error_info))) - .unwrap(); - } - - // Step 14 - self.in_error_reporting_mode.set(false); + pub fn forward_error_to_worker_object(&self, error_info: ErrorInfo) { + let worker = self.worker.borrow().as_ref().unwrap().clone(); + // TODO: Should use the DOM manipulation task source. + self.parent_sender + .send(CommonScriptMsg::RunnableMsg(WorkerEvent, + box WorkerErrorHandler::new(worker, error_info))) + .unwrap(); } } diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 15df6ee4e33..ed550309a3c 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -25,7 +25,6 @@ use dom::htmlelement::HTMLElement; use dom::node::{ChildrenMutation, CloneChildrenFlag, Node}; use dom::node::{document_from_node, window_from_node}; use dom::virtualmethods::VirtualMethods; -use dom::window::ScriptHelpers; use encoding::label::encoding_from_whatwg_label; use encoding::types::{DecoderTrap, EncodingRef}; use html5ever::tree_builder::NextParserState; @@ -507,9 +506,8 @@ impl HTMLScriptElement { // Step 5.a.2. let window = window_from_node(self); rooted!(in(window.get_cx()) let mut rval = UndefinedValue()); - window.evaluate_script_on_global_with_result(&script.text, - script.url.as_str(), - rval.handle_mut()); + GlobalRef::Window(&window).evaluate_script_on_global_with_result( + &script.text, script.url.as_str(), rval.handle_mut()); // Step 6. document.set_current_script(old_script.r()); diff --git a/components/script/dom/serviceworkerglobalscope.rs b/components/script/dom/serviceworkerglobalscope.rs index f6208b63586..6efd555c909 100644 --- a/components/script/dom/serviceworkerglobalscope.rs +++ b/components/script/dom/serviceworkerglobalscope.rs @@ -23,7 +23,6 @@ use ipc_channel::router::ROUTER; use js::jsapi::{JS_SetInterruptCallback, JSAutoCompartment, JSContext}; use js::jsval::UndefinedValue; use js::rust::Runtime; -use msg::constellation_msg::PipelineId; use net_traits::{LoadContext, load_whole_resource, IpcSend, CustomResponseMediator}; use rand::random; use script_runtime::{CommonScriptMsg, StackRootTLS, get_reports, new_rt_and_cx, ScriptChan}; @@ -72,7 +71,6 @@ impl ScriptChan for ServiceWorkerChan { #[dom_struct] pub struct ServiceWorkerGlobalScope { workerglobalscope: WorkerGlobalScope, - id: PipelineId, #[ignore_heap_size_of = "Defined in std"] receiver: Receiver<ServiceWorkerScriptMsg>, #[ignore_heap_size_of = "Defined in std"] @@ -87,7 +85,6 @@ pub struct ServiceWorkerGlobalScope { impl ServiceWorkerGlobalScope { fn new_inherited(init: WorkerGlobalScopeInit, worker_url: Url, - id: PipelineId, from_devtools_receiver: Receiver<DevtoolScriptControlMsg>, runtime: Runtime, own_sender: Sender<ServiceWorkerScriptMsg>, @@ -104,7 +101,6 @@ impl ServiceWorkerGlobalScope { from_devtools_receiver, timer_event_chan, None), - id: id, receiver: receiver, timer_event_port: timer_event_port, own_sender: own_sender, @@ -115,7 +111,6 @@ impl ServiceWorkerGlobalScope { pub fn new(init: WorkerGlobalScopeInit, worker_url: Url, - id: PipelineId, from_devtools_receiver: Receiver<DevtoolScriptControlMsg>, runtime: Runtime, own_sender: Sender<ServiceWorkerScriptMsg>, @@ -128,7 +123,6 @@ impl ServiceWorkerGlobalScope { let cx = runtime.cx(); let scope = box ServiceWorkerGlobalScope::new_inherited(init, worker_url, - id, from_devtools_receiver, runtime, own_sender, @@ -148,7 +142,6 @@ impl ServiceWorkerGlobalScope { swmanager_sender: IpcSender<ServiceWorkerMsg>, scope_url: Url) { let ScopeThings { script_url, - pipeline_id, init, worker_load_origin, .. } = scope_things; @@ -179,7 +172,7 @@ impl ServiceWorkerGlobalScope { let (timer_ipc_chan, _timer_ipc_port) = ipc::channel().unwrap(); let (timer_chan, timer_port) = channel(); let global = ServiceWorkerGlobalScope::new( - init, url, pipeline_id, devtools_mpsc_port, runtime, + init, url, devtools_mpsc_port, runtime, own_sender, receiver, timer_ipc_chan, timer_port, swmanager_sender, scope_url); let scope = global.upcast::<WorkerGlobalScope>(); @@ -298,10 +291,6 @@ impl ServiceWorkerGlobalScope { } } - pub fn pipeline_id(&self) -> PipelineId { - self.id - } - pub fn process_event(&self, msg: CommonScriptMsg) { self.handle_script_event(ServiceWorkerScriptMsg::CommonWorker(WorkerScriptMsg::Common(msg))); } diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 10d47f161be..3ac5c4e37f9 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -16,7 +16,7 @@ use dom::bindings::codegen::Bindings::RequestBinding::RequestInit; use dom::bindings::codegen::Bindings::WindowBinding::{self, FrameRequestCallback, WindowMethods}; use dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, ScrollToOptions}; use dom::bindings::codegen::UnionTypes::RequestOrUSVString; -use dom::bindings::error::{Error, ErrorInfo, ErrorResult, Fallible, report_pending_exception}; +use dom::bindings::error::{Error, ErrorInfo, ErrorResult, Fallible}; use dom::bindings::global::{GlobalRef, global_root_from_object}; use dom::bindings::inheritance::Castable; use dom::bindings::js::{JS, MutNullableHeap, Root}; @@ -49,12 +49,10 @@ use euclid::{Point2D, Rect, Size2D}; use fetch; use gfx_traits::LayerId; use ipc_channel::ipc::{self, IpcSender}; -use js::jsapi::{Evaluate2, HandleObject, HandleValue, JSAutoCompartment, JSContext}; -use js::jsapi::{JS_GC, JS_GetRuntime, MutableHandleValue, SetWindowProxy}; +use js::jsapi::{HandleObject, HandleValue, JSAutoCompartment, JSContext}; +use js::jsapi::{JS_GC, JS_GetRuntime, SetWindowProxy}; use js::jsval::UndefinedValue; -use js::rust::CompileOptionsWrapper; use js::rust::Runtime; -use libc; use msg::constellation_msg::{FrameType, LoadData, PipelineId, ReferrerPolicy, WindowSizeType}; use net_traits::ResourceThreads; use net_traits::bluetooth_thread::BluetoothMethodMsg; @@ -64,15 +62,14 @@ use num_traits::ToPrimitive; use open; use origin::Origin; use profile_traits::mem; -use profile_traits::time::{ProfilerCategory, TimerMetadata, TimerMetadataFrameType}; -use profile_traits::time::{ProfilerChan, TimerMetadataReflowType, profile}; +use profile_traits::time::ProfilerChan; use rustc_serialize::base64::{FromBase64, STANDARD, ToBase64}; use script_layout_interface::TrustedNodeAddress; use script_layout_interface::message::{Msg, Reflow, ReflowQueryType, ScriptReflow}; use script_layout_interface::reporter::CSSErrorReporter; use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse, LayoutRPC}; use script_layout_interface::rpc::{MarginStyleResponse, ResolvedStyleResponse}; -use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, ScriptThreadEventCategory, maybe_take_panic_result}; +use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, ScriptThreadEventCategory}; use script_thread::{MainThreadScriptChan, MainThreadScriptMsg, Runnable, RunnableWrapper}; use script_thread::SendableMainThreadScriptChan; use script_traits::{ConstellationControlMsg, MozBrowserEvent, UntrustedNodeAddress}; @@ -84,9 +81,7 @@ use std::borrow::ToOwned; use std::cell::Cell; use std::collections::{HashMap, HashSet}; use std::default::Default; -use std::ffi::CString; use std::io::{Write, stderr, stdout}; -use std::panic; use std::rc::Rc; use std::sync::{Arc, Mutex}; use std::sync::atomic::{AtomicBool, Ordering}; @@ -913,61 +908,6 @@ impl WindowMethods for Window { } } -pub trait ScriptHelpers { - fn evaluate_js_on_global_with_result(self, code: &str, - rval: MutableHandleValue); - fn evaluate_script_on_global_with_result(self, code: &str, filename: &str, - rval: MutableHandleValue); -} - -impl<'a, T: Reflectable> ScriptHelpers for &'a T { - fn evaluate_js_on_global_with_result(self, code: &str, - rval: MutableHandleValue) { - self.evaluate_script_on_global_with_result(code, "", rval) - } - - #[allow(unsafe_code)] - fn evaluate_script_on_global_with_result(self, code: &str, filename: &str, - rval: MutableHandleValue) { - let global = self.global(); - let metadata = TimerMetadata { - url: if filename.is_empty() { - global.r().get_url().as_str().into() - } else { - filename.into() - }, - iframe: TimerMetadataFrameType::RootWindow, - incremental: TimerMetadataReflowType::FirstReflow, - }; - profile( - ProfilerCategory::ScriptEvaluate, - Some(metadata), - global.r().time_profiler_chan().clone(), - || { - let cx = global.r().get_cx(); - let globalhandle = global.r().reflector().get_jsobject(); - let code: Vec<u16> = code.encode_utf16().collect(); - let filename = CString::new(filename).unwrap(); - - let _ac = JSAutoCompartment::new(cx, globalhandle.get()); - let options = CompileOptionsWrapper::new(cx, filename.as_ptr(), 1); - unsafe { - if !Evaluate2(cx, options.ptr, code.as_ptr(), - code.len() as libc::size_t, - rval) { - debug!("error evaluating JS string"); - report_pending_exception(cx, true); - } - } - - if let Some(error) = maybe_take_panic_result() { - panic::resume_unwind(error); - } - } - ) - } -} - impl Window { pub fn get_runnable_wrapper(&self) -> RunnableWrapper { RunnableWrapper { diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 1821b2d2dee..fb6b170ab1d 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -106,7 +106,7 @@ impl Worker { let init = prepare_workerscope_init(global, Some(devtools_sender)); DedicatedWorkerGlobalScope::run_worker_scope( - init, worker_url, global.pipeline_id(), devtools_receiver, worker.runtime.clone(), worker_ref, + init, worker_url, devtools_receiver, worker.runtime.clone(), worker_ref, global.script_chan(), sender, receiver, worker_load_origin, closing); Ok(worker) diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index f2809537316..9c7768ce5e7 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -18,6 +18,9 @@ use dom::bindings::str::DOMString; use dom::console::TimerSet; use dom::crypto::Crypto; use dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope; +use dom::errorevent::ErrorEvent; +use dom::event::{Event, EventBubbles, EventCancelable}; +use dom::eventdispatcher::EventStatus; use dom::eventtarget::EventTarget; use dom::promise::Promise; use dom::serviceworkerglobalscope::ServiceWorkerGlobalScope; @@ -66,7 +69,8 @@ pub fn prepare_workerscope_init(global: GlobalRef, from_devtools_sender: devtools_sender, constellation_chan: global.constellation_chan().clone(), scheduler_chan: global.scheduler_chan().clone(), - worker_id: worker_id + worker_id: worker_id, + pipeline_id: global.pipeline_id(), }; init @@ -77,6 +81,7 @@ pub fn prepare_workerscope_init(global: GlobalRef, pub struct WorkerGlobalScope { eventtarget: EventTarget, worker_id: WorkerId, + pipeline_id: PipelineId, worker_url: Url, closing: Option<Arc<AtomicBool>>, #[ignore_heap_size_of = "Defined in js"] @@ -120,6 +125,9 @@ pub struct WorkerGlobalScope { console_timers: TimerSet, promise_job_queue: PromiseJobQueue, + + /// https://html.spec.whatwg.org/multipage/#in-error-reporting-mode + in_error_reporting_mode: Cell<bool> } impl WorkerGlobalScope { @@ -134,6 +142,7 @@ impl WorkerGlobalScope { eventtarget: EventTarget::new_inherited(), next_worker_id: Cell::new(WorkerId(0)), worker_id: init.worker_id, + pipeline_id: init.pipeline_id, worker_url: worker_url, closing: closing, runtime: runtime, @@ -152,6 +161,7 @@ impl WorkerGlobalScope { scheduler_chan: init.scheduler_chan, console_timers: TimerSet::new(), promise_job_queue: PromiseJobQueue::new(), + in_error_reporting_mode: Default::default(), } } @@ -447,15 +457,7 @@ impl WorkerGlobalScope { } pub fn pipeline_id(&self) -> PipelineId { - let dedicated = self.downcast::<DedicatedWorkerGlobalScope>(); - let service_worker = self.downcast::<ServiceWorkerGlobalScope>(); - if let Some(dedicated) = dedicated { - return dedicated.pipeline_id(); - } else if let Some(service_worker) = service_worker { - return service_worker.pipeline_id(); - } else { - panic!("need to implement a sender for SharedWorker") - } + self.pipeline_id } pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) { @@ -495,9 +497,38 @@ impl WorkerGlobalScope { /// https://html.spec.whatwg.org/multipage/#report-the-error pub fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue) { - self.downcast::<DedicatedWorkerGlobalScope>() - .expect("Should implement report_an_error for this worker") - .report_an_error(error_info, value); + // Step 1. + if self.in_error_reporting_mode.get() { + return; + } + + // Step 2. + self.in_error_reporting_mode.set(true); + + // Steps 3-12. + // FIXME(#13195): muted errors. + let event = ErrorEvent::new(GlobalRef::Worker(self), + atom!("error"), + EventBubbles::DoesNotBubble, + EventCancelable::Cancelable, + error_info.message.as_str().into(), + error_info.filename.as_str().into(), + error_info.lineno, + error_info.column, + value); + + // Step 13. + let event_status = event.upcast::<Event>().fire(self.upcast::<EventTarget>()); + + // Step 15 + if event_status == EventStatus::NotCanceled { + if let Some(dedicated) = self.downcast::<DedicatedWorkerGlobalScope>() { + dedicated.forward_error_to_worker_object(error_info); + } + } + + // Step 14 + self.in_error_reporting_mode.set(false); } } diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index f1878501500..282fd90a08b 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -46,7 +46,7 @@ use dom::serviceworker::TrustedServiceWorkerAddress; use dom::serviceworkerregistration::ServiceWorkerRegistration; use dom::servohtmlparser::ParserContext; use dom::uievent::UIEvent; -use dom::window::{ReflowReason, ScriptHelpers, Window}; +use dom::window::{ReflowReason, Window}; use dom::worker::TrustedWorkerAddress; use euclid::Rect; use euclid::point::Point2D; @@ -1775,7 +1775,8 @@ impl ScriptThread { unsafe { let _ac = JSAutoCompartment::new(self.get_cx(), window.reflector().get_jsobject().get()); rooted!(in(self.get_cx()) let mut jsval = UndefinedValue()); - window.evaluate_js_on_global_with_result(&script_source, jsval.handle_mut()); + GlobalRef::Window(&window).evaluate_js_on_global_with_result( + &script_source, jsval.handle_mut()); let strval = DOMString::from_jsval(self.get_cx(), jsval.handle(), StringificationBehavior::Empty); diff --git a/components/script/timers.rs b/components/script/timers.rs index f75ebf907d5..601755c6fc4 100644 --- a/components/script/timers.rs +++ b/components/script/timers.rs @@ -9,7 +9,6 @@ use dom::bindings::global::GlobalRef; use dom::bindings::reflector::Reflectable; use dom::bindings::str::DOMString; use dom::testbinding::TestBindingCallback; -use dom::window::ScriptHelpers; use dom::xmlhttprequest::XHRTimeoutCallback; use euclid::length::Length; use heapsize::HeapSizeOf; @@ -490,10 +489,12 @@ impl JsTimerTask { // step 4.2 match *&self.callback { InternalTimerCallback::StringTimerCallback(ref code_str) => { - let cx = this.global().r().get_cx(); + let global = this.global(); + let cx = global.r().get_cx(); rooted!(in(cx) let mut rval = UndefinedValue()); - this.evaluate_js_on_global_with_result(code_str, rval.handle_mut()); + global.r().evaluate_js_on_global_with_result( + code_str, rval.handle_mut()); }, InternalTimerCallback::FunctionTimerCallback(ref function, ref arguments) => { let arguments: Vec<JSVal> = arguments.iter().map(|arg| arg.get()).collect(); diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index b4e80bddac7..03281464765 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -13,6 +13,7 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, StringificationBehavior}; +use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::str::DOMString; @@ -23,7 +24,6 @@ use dom::htmliframeelement::HTMLIFrameElement; use dom::htmlinputelement::HTMLInputElement; use dom::htmloptionelement::HTMLOptionElement; use dom::node::Node; -use dom::window::ScriptHelpers; use euclid::point::Point2D; use euclid::rect::Rect; use euclid::size::Size2D; @@ -92,7 +92,8 @@ pub fn handle_execute_script(context: &BrowsingContext, let result = unsafe { let cx = window.get_cx(); rooted!(in(cx) let mut rval = UndefinedValue()); - window.evaluate_js_on_global_with_result(&eval, rval.handle_mut()); + GlobalRef::Window(&window).evaluate_js_on_global_with_result( + &eval, rval.handle_mut()); jsval_to_webdriver(cx, rval.handle()) }; reply.send(result).unwrap(); @@ -111,7 +112,8 @@ pub fn handle_execute_async_script(context: &BrowsingContext, let cx = window.get_cx(); window.set_webdriver_script_chan(Some(reply)); rooted!(in(cx) let mut rval = UndefinedValue()); - window.evaluate_js_on_global_with_result(&eval, rval.handle_mut()); + GlobalRef::Window(&window).evaluate_js_on_global_with_result( + &eval, rval.handle_mut()); } pub fn handle_get_frame_id(context: &BrowsingContext, diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index c28942688e5..65c52153a63 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -663,6 +663,8 @@ pub struct WorkerGlobalScopeInit { pub scheduler_chan: IpcSender<TimerEventRequest>, /// The worker id pub worker_id: WorkerId, + /// The pipeline id + pub pipeline_id: PipelineId, } /// Common entities representing a network load origin |