Implement the entry global.

Partial fix for #10963.
This commit is contained in:
Ms2ger 2016-12-29 13:39:12 +01:00
parent 839b7fe8ef
commit cb47a7e403
15 changed files with 156 additions and 0 deletions

View file

@ -10,6 +10,7 @@ use dom::bindings::error::{ErrorInfo, report_pending_exception};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{MutNullableJS, Root};
use dom::bindings::reflector::DomObject;
use dom::bindings::settings_stack::{AutoEntryScript, entry_global};
use dom::bindings::str::DOMString;
use dom::crypto::Crypto;
use dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope;
@ -365,6 +366,7 @@ impl GlobalScope {
let filename = CString::new(filename).unwrap();
let _ac = JSAutoCompartment::new(cx, globalhandle.get());
let _aes = AutoEntryScript::new(self);
let options = CompileOptionsWrapper::new(cx, filename.as_ptr(), 1);
unsafe {
if !Evaluate2(cx, options.ptr, code.as_ptr(),
@ -519,6 +521,13 @@ impl GlobalScope {
global_scope_from_global(global)
}
}
/// Returns the ["entry"] global object.
///
/// ["entry"]: https://html.spec.whatwg.org/multipage/#entry
pub fn entry() -> Root<Self> {
entry_global()
}
}
fn timestamp_in_ms(time: Timespec) -> u64 {