mirror of
https://github.com/servo/servo.git
synced 2025-06-15 11:54:28 +00:00
Implement DedicatedWorkerGlobalScope.navigator.
This commit is contained in:
parent
f300e146b0
commit
eadb1c154a
19 changed files with 87 additions and 73 deletions
|
@ -13,15 +13,13 @@ interface WorkerGlobalScope : EventTarget {
|
||||||
// attribute EventHandler onlanguagechange;
|
// attribute EventHandler onlanguagechange;
|
||||||
// attribute EventHandler onoffline;
|
// attribute EventHandler onoffline;
|
||||||
// attribute EventHandler ononline;
|
// attribute EventHandler ononline;
|
||||||
|
|
||||||
// also has obsolete members
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// http://www.whatwg.org/html/#WorkerGlobalScope-partial
|
// http://www.whatwg.org/html/#WorkerGlobalScope-partial
|
||||||
//[Exposed=Worker]
|
//[Exposed=Worker]
|
||||||
partial interface WorkerGlobalScope {
|
partial interface WorkerGlobalScope { // not obsolete
|
||||||
//void importScripts(DOMString... urls);
|
//void importScripts(DOMString... urls);
|
||||||
//readonly attribute WorkerNavigator navigator;
|
readonly attribute WorkerNavigator navigator;
|
||||||
};
|
};
|
||||||
//WorkerGlobalScope implements WindowTimers;
|
//WorkerGlobalScope implements WindowTimers;
|
||||||
//WorkerGlobalScope implements WindowBase64;
|
//WorkerGlobalScope implements WindowBase64;
|
||||||
|
|
11
src/components/script/dom/webidls/WorkerNavigator.webidl
Normal file
11
src/components/script/dom/webidls/WorkerNavigator.webidl
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
// http://www.whatwg.org/html/#workernavigator
|
||||||
|
//[Exposed=Worker]
|
||||||
|
interface WorkerNavigator {};
|
||||||
|
WorkerNavigator implements NavigatorID;
|
||||||
|
//WorkerNavigator implements NavigatorLanguage;
|
||||||
|
//WorkerNavigator implements NavigatorOnLine;
|
|
@ -9,6 +9,7 @@ use dom::bindings::js::{JS, JSRef, Temporary, OptionalSettable};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
use dom::console::Console;
|
use dom::console::Console;
|
||||||
use dom::eventtarget::{EventTarget, WorkerGlobalScopeTypeId};
|
use dom::eventtarget::{EventTarget, WorkerGlobalScopeTypeId};
|
||||||
|
use dom::workernavigator::WorkerNavigator;
|
||||||
use script_task::ScriptChan;
|
use script_task::ScriptChan;
|
||||||
|
|
||||||
use servo_net::resource_task::ResourceTask;
|
use servo_net::resource_task::ResourceTask;
|
||||||
|
@ -32,6 +33,7 @@ pub struct WorkerGlobalScope {
|
||||||
js_context: Untraceable<Rc<Cx>>,
|
js_context: Untraceable<Rc<Cx>>,
|
||||||
resource_task: Untraceable<ResourceTask>,
|
resource_task: Untraceable<ResourceTask>,
|
||||||
script_chan: ScriptChan,
|
script_chan: ScriptChan,
|
||||||
|
navigator: Cell<Option<JS<WorkerNavigator>>>,
|
||||||
console: Cell<Option<JS<Console>>>,
|
console: Cell<Option<JS<Console>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +49,7 @@ impl WorkerGlobalScope {
|
||||||
js_context: Untraceable::new(cx),
|
js_context: Untraceable::new(cx),
|
||||||
resource_task: Untraceable::new(resource_task),
|
resource_task: Untraceable::new(resource_task),
|
||||||
script_chan: script_chan,
|
script_chan: script_chan,
|
||||||
|
navigator: Cell::new(None),
|
||||||
console: Cell::new(None),
|
console: Cell::new(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +76,14 @@ impl<'a> WorkerGlobalScopeMethods for JSRef<'a, WorkerGlobalScope> {
|
||||||
Temporary::from_rooted(self)
|
Temporary::from_rooted(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn Navigator(&self) -> Temporary<WorkerNavigator> {
|
||||||
|
if self.navigator.get().is_none() {
|
||||||
|
let navigator = WorkerNavigator::new(self);
|
||||||
|
self.navigator.assign(Some(navigator));
|
||||||
|
}
|
||||||
|
Temporary::new(self.navigator.get().get_ref().clone())
|
||||||
|
}
|
||||||
|
|
||||||
fn Console(&self) -> Temporary<Console> {
|
fn Console(&self) -> Temporary<Console> {
|
||||||
if self.console.get().is_none() {
|
if self.console.get().is_none() {
|
||||||
let console = Console::new(&global::Worker(*self));
|
let console = Console::new(&global::Worker(*self));
|
||||||
|
|
58
src/components/script/dom/workernavigator.rs
Normal file
58
src/components/script/dom/workernavigator.rs
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
/* 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::WorkerNavigatorBinding;
|
||||||
|
use dom::bindings::codegen::Bindings::WorkerNavigatorBinding::WorkerNavigatorMethods;
|
||||||
|
use dom::bindings::global::Worker;
|
||||||
|
use dom::bindings::js::{JSRef, Temporary};
|
||||||
|
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||||
|
use dom::workerglobalscope::WorkerGlobalScope;
|
||||||
|
use servo_util::str::DOMString;
|
||||||
|
|
||||||
|
#[deriving(Encodable)]
|
||||||
|
pub struct WorkerNavigator {
|
||||||
|
reflector_: Reflector,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WorkerNavigator {
|
||||||
|
pub fn new_inherited() -> WorkerNavigator {
|
||||||
|
WorkerNavigator {
|
||||||
|
reflector_: Reflector::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new(global: &JSRef<WorkerGlobalScope>) -> Temporary<WorkerNavigator> {
|
||||||
|
reflect_dom_object(box WorkerNavigator::new_inherited(),
|
||||||
|
&Worker(*global),
|
||||||
|
WorkerNavigatorBinding::Wrap)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> WorkerNavigatorMethods for JSRef<'a, WorkerNavigator> {
|
||||||
|
fn Product(&self) -> DOMString {
|
||||||
|
"Gecko".to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn TaintEnabled(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
fn AppName(&self) -> DOMString {
|
||||||
|
"Netscape".to_string() // Like Gecko/Webkit
|
||||||
|
}
|
||||||
|
|
||||||
|
fn AppCodeName(&self) -> DOMString {
|
||||||
|
"Mozilla".to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn Platform(&self) -> DOMString {
|
||||||
|
"".to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Reflectable for WorkerNavigator {
|
||||||
|
fn reflector<'a>(&'a self) -> &'a Reflector {
|
||||||
|
&self.reflector_
|
||||||
|
}
|
||||||
|
}
|
|
@ -191,6 +191,7 @@ pub mod dom {
|
||||||
pub mod window;
|
pub mod window;
|
||||||
pub mod worker;
|
pub mod worker;
|
||||||
pub mod workerglobalscope;
|
pub mod workerglobalscope;
|
||||||
|
pub mod workernavigator;
|
||||||
pub mod xmlhttprequest;
|
pub mod xmlhttprequest;
|
||||||
pub mod xmlhttprequesteventtarget;
|
pub mod xmlhttprequesteventtarget;
|
||||||
pub mod xmlhttprequestupload;
|
pub mod xmlhttprequestupload;
|
||||||
|
|
|
@ -163,6 +163,7 @@ var interfaceNamesInGlobalScope = [
|
||||||
"Window",
|
"Window",
|
||||||
"Worker",
|
"Worker",
|
||||||
"WorkerGlobalScope", // #2823
|
"WorkerGlobalScope", // #2823
|
||||||
|
"WorkerNavigator", // #2823
|
||||||
"XMLHttpRequest",
|
"XMLHttpRequest",
|
||||||
"XMLHttpRequestUpload",
|
"XMLHttpRequestUpload",
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[WorkerNavigator_appName.htm]
|
|
||||||
type: testharness
|
|
||||||
expected: TIMEOUT
|
|
||||||
[Test Description: WorkerNavigator appName: Returns the name of the browser.]
|
|
||||||
expected: NOTRUN
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[WorkerNavigator_appVersion.htm]
|
|
||||||
type: testharness
|
|
||||||
expected: TIMEOUT
|
|
||||||
[Test Description: WorkerNavigator appVersion: Returns the version of the browser.]
|
|
||||||
expected: NOTRUN
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[WorkerNavigator_onLine.htm]
|
|
||||||
type: testharness
|
|
||||||
expected: TIMEOUT
|
|
||||||
[Test Description: WorkerNavigator implements NavigatorOnLine.]
|
|
||||||
expected: NOTRUN
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[WorkerNavigator_platform.htm]
|
|
||||||
type: testharness
|
|
||||||
expected: TIMEOUT
|
|
||||||
[Test Description: WorkerNavigator.platform returns the name of the platform: ]
|
|
||||||
expected: NOTRUN
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[WorkerNavigator_userAgent.htm]
|
|
||||||
type: testharness
|
|
||||||
expected: TIMEOUT
|
|
||||||
[Test Description: WorkerNavigator.userAgent returns the complete User-Agent header: undefined]
|
|
||||||
expected: NOTRUN
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[002.html]
|
|
||||||
type: testharness
|
|
||||||
expected: TIMEOUT
|
|
||||||
[navigator.appName]
|
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[003.html]
|
|
||||||
type: testharness
|
|
||||||
expected: TIMEOUT
|
|
||||||
[navigator.appVersion]
|
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[004.html]
|
|
||||||
type: testharness
|
|
||||||
expected: TIMEOUT
|
|
||||||
[navigator.platform]
|
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[005.html]
|
|
||||||
type: testharness
|
|
||||||
expected: TIMEOUT
|
|
||||||
[navigator.userAgent]
|
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[006.html]
|
|
||||||
type: testharness
|
|
||||||
expected: TIMEOUT
|
|
||||||
[navigator.onLine]
|
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
[007.html]
|
[007.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
expected: TIMEOUT
|
|
||||||
[readonlyness of members of Navigator]
|
[readonlyness of members of Navigator]
|
||||||
expected: TIMEOUT
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[language.html]
|
|
||||||
type: testharness
|
|
||||||
expected: TIMEOUT
|
|
||||||
[navigator.language]
|
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
[postMessage_DataCloneErr.htm]
|
[postMessage_DataCloneErr.htm]
|
||||||
type: testharness
|
type: testharness
|
||||||
|
expected: TIMEOUT
|
||||||
[Test Description: Throw a DATA_CLONE_ERR exception when a host object (e.g. a DOM node) is used with postMessage.]
|
[Test Description: Throw a DATA_CLONE_ERR exception when a host object (e.g. a DOM node) is used with postMessage.]
|
||||||
expected: FAIL
|
expected: NOTRUN
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue