aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/serviceworkercontainer.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-09-19 17:47:27 -0400
committerGitHub <noreply@github.com>2018-09-19 17:47:27 -0400
commitdf2adebefdfa3da49f173e480fa1e56450f9bda2 (patch)
tree1f05b49bac02318455a59d5b143c186fd872bdb9 /components/script/dom/serviceworkercontainer.rs
parent2ca7a134736bb4759ff209c1bc0b6dc3cc1984c9 (diff)
parentc37a345dc9f4dda6ea29c42f96f6c7201c42cbac (diff)
downloadservo-df2adebefdfa3da49f173e480fa1e56450f9bda2.tar.gz
servo-df2adebefdfa3da49f173e480fa1e56450f9bda2.zip
Auto merge of #21737 - chansuke:format_script, r=jdm
Format script component --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix part of #21373. - [x] These changes do not require tests because they format code only. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21737) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/serviceworkercontainer.rs')
-rw-r--r--components/script/dom/serviceworkercontainer.rs38
1 files changed, 24 insertions, 14 deletions
diff --git a/components/script/dom/serviceworkercontainer.rs b/components/script/dom/serviceworkercontainer.rs
index d6886d541eb..2b73927adab 100644
--- a/components/script/dom/serviceworkercontainer.rs
+++ b/components/script/dom/serviceworkercontainer.rs
@@ -23,7 +23,7 @@ use std::rc::Rc;
pub struct ServiceWorkerContainer {
eventtarget: EventTarget,
controller: MutNullableDom<ServiceWorker>,
- client: Dom<Client>
+ client: Dom<Client>,
}
impl ServiceWorkerContainer {
@@ -52,9 +52,7 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
#[allow(unrooted_must_root)]
// https://w3c.github.io/ServiceWorker/#service-worker-container-register-method and - A
// https://w3c.github.io/ServiceWorker/#start-register-algorithm - B
- fn Register(&self,
- script_url: USVString,
- options: &RegistrationOptions) -> Rc<Promise> {
+ fn Register(&self, script_url: USVString, options: &RegistrationOptions) -> Rc<Promise> {
// A: Step 1
let promise = Promise::new(&*self.global());
let USVString(ref script_url) = script_url;
@@ -65,7 +63,7 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
Err(_) => {
promise.reject_error(Error::Type("Invalid script URL".to_owned()));
return promise;
- }
+ },
};
// B: Step 2
match script_url.scheme() {
@@ -73,12 +71,15 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
_ => {
promise.reject_error(Error::Type("Only secure origins are allowed".to_owned()));
return promise;
- }
+ },
}
// B: Step 3
if script_url.path().to_ascii_lowercase().contains("%2f") ||
- script_url.path().to_ascii_lowercase().contains("%5c") {
- promise.reject_error(Error::Type("Script URL contains forbidden characters".to_owned()));
+ script_url.path().to_ascii_lowercase().contains("%5c")
+ {
+ promise.reject_error(Error::Type(
+ "Script URL contains forbidden characters".to_owned(),
+ ));
return promise;
}
// B: Step 4-5
@@ -90,10 +91,10 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
Err(_) => {
promise.reject_error(Error::Type("Invalid scope URL".to_owned()));
return promise;
- }
+ },
}
},
- None => script_url.join("./").unwrap()
+ None => script_url.join("./").unwrap(),
};
// B: Step 6
match scope.scheme() {
@@ -101,17 +102,26 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
_ => {
promise.reject_error(Error::Type("Only secure origins are allowed".to_owned()));
return promise;
- }
+ },
}
// B: Step 7
if scope.path().to_ascii_lowercase().contains("%2f") ||
- scope.path().to_ascii_lowercase().contains("%5c") {
- promise.reject_error(Error::Type("Scope URL contains forbidden characters".to_owned()));
+ scope.path().to_ascii_lowercase().contains("%5c")
+ {
+ promise.reject_error(Error::Type(
+ "Scope URL contains forbidden characters".to_owned(),
+ ));
return promise;
}
// B: Step 8
- let job = Job::create_job(JobType::Register, scope, script_url, promise.clone(), &*self.client);
+ let job = Job::create_job(
+ JobType::Register,
+ scope,
+ script_url,
+ promise.clone(),
+ &*self.client,
+ );
ScriptThread::schedule_job(job);
promise
}