script: Ensure script is initialized before running script.

Fixes #14154
This commit is contained in:
Emilio Cobos Álvarez 2016-11-12 02:27:51 +01:00
parent d49840eeec
commit a7cee44f59
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 13 additions and 6 deletions

View file

@ -170,6 +170,10 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
})
};
// Important that this call is done in a single-threaded fashion, we
// can't defer it after `create_constellation` has started.
script::init();
// Create the constellation, which maintains the engine
// pipelines, including the script and layout threads, as well
// as the navigation context.
@ -183,7 +187,7 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
webrender_api_sender.clone());
// Send the constellation's swmanager sender to service worker manager thread
script::init(sw_senders);
script::init_service_workers(sw_senders);
if cfg!(feature = "webdriver") {
if let Some(port) = opts.webdriver_port {
@ -339,7 +343,8 @@ pub fn run_content_process(token: String) {
// send the required channels to the service worker manager
let sw_senders = unprivileged_content.swmanager_senders();
script::init(sw_senders);
script::init();
script::init_service_workers(sw_senders);
unprivileged_content.start_all::<script_layout_interface::message::Msg,
layout_thread::LayoutThread,