From 25abe8b289e967b3fcd7bc57040a2432646fb2bd Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sun, 13 Jul 2014 18:15:24 +0200 Subject: [PATCH] Parse the URL passed to the Worker constructor. --- src/components/script/dom/worker.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/script/dom/worker.rs b/src/components/script/dom/worker.rs index 6c79525a139..5a62f1c37f4 100644 --- a/src/components/script/dom/worker.rs +++ b/src/components/script/dom/worker.rs @@ -2,13 +2,14 @@ * 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::error::{Fallible, Security}; +use dom::bindings::error::{Fallible, Security, Syntax}; use dom::bindings::global::GlobalRef; use dom::bindings::js::Temporary; use dom::bindings::utils::{Reflectable, Reflector}; use dom::eventtarget::EventTarget; use servo_util::str::DOMString; +use servo_util::url::try_parse_url; #[deriving(Encodable)] pub struct Worker { @@ -16,7 +17,13 @@ pub struct Worker { } impl Worker { - pub fn Constructor(_global: &GlobalRef, _scriptURL: DOMString) -> Fallible> { + pub fn Constructor(global: &GlobalRef, scriptURL: DOMString) -> Fallible> { + // Step 2-4. + let _worker_url = match try_parse_url(scriptURL.as_slice(), Some(global.get_url())) { + Ok(url) => url, + Err(_) => return Err(Syntax), + }; + Err(Security) } }