Skip to content

Commit

Permalink
Update checking origin trustworthy align to spec
Browse files Browse the repository at this point in the history
  • Loading branch information
CYBAI committed Apr 13, 2020
1 parent 06803a2 commit 99a8ea2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
9 changes: 7 additions & 2 deletions components/script/dom/urlhelper.rs
Expand Up @@ -74,14 +74,19 @@ impl UrlHelper {
}
// https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy
pub fn is_origin_trustworthy(url: &ServoUrl) -> bool {
// Step 1
if !url.origin().is_tuple() {
return false;
}

// Step 3
if url.scheme() == "http" || url.scheme() == "wss" {
if url.scheme() == "https" || url.scheme() == "wss" {
true
// Step 4
} else if url.host().is_some() {
let host = url.host_str().unwrap();
host == "127.0.0.0/8" || host == "::1/128"
// Step 5
// Step 6
} else {
url.scheme() == "file"
}
Expand Down
@@ -1,4 +1,4 @@
[service-worker-registration.html]
[service-worker-registration.https.html]
[Test: Throws Error when Invalid Scope]
expected: FAIL

Expand Down
4 changes: 2 additions & 2 deletions tests/wpt/mozilla/meta/MANIFEST.json
Expand Up @@ -14273,8 +14273,8 @@
]
],
"service-workers": {
"service-worker-registration.html": [
"da46088ca92d8706c40a48fdb3805aaf28bbddd5",
"service-worker-registration.https.html": [
"949992e45de6858c336936b4f1ea4bca76db1d91",
[
null,
{}
Expand Down
Expand Up @@ -16,7 +16,7 @@

promise_test(function() {
return register_sw('resources/sw.js').then(function(sw_reg) {
assert_equals(sw_reg.active.scriptURL, location.href.replace("service-worker-registration.html", "resources/sw.js"));
assert_equals(sw_reg.active.scriptURL, location.href.replace("service-worker-registration.https.html", "resources/sw.js"));
});
}, "Test: Active Service Worker ScriptURL property");

Expand All @@ -30,7 +30,7 @@

promise_test(function() {
return register_sw('resources/sw.js', './').then(function(sw_reg) {
assert_equals(sw_reg.scope, location.href.replace("service-worker-registration.html", ""));
assert_equals(sw_reg.scope, location.href.replace("service-worker-registration.https.html", ""));
});
}, "Test: Service Worker Registration property scope Url when no scope");

Expand Down

0 comments on commit 99a8ea2

Please sign in to comment.