diff --git a/components/script/dom/urlhelper.rs b/components/script/dom/urlhelper.rs index 144212e0600..b03ce4c3f9d 100644 --- a/components/script/dom/urlhelper.rs +++ b/components/script/dom/urlhelper.rs @@ -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" } diff --git a/tests/wpt/mozilla/meta-layout-2020/mozilla/service-workers/service-worker-registration.html.ini b/tests/wpt/mozilla/meta-layout-2020/mozilla/service-workers/service-worker-registration.https.html.ini similarity index 92% rename from tests/wpt/mozilla/meta-layout-2020/mozilla/service-workers/service-worker-registration.html.ini rename to tests/wpt/mozilla/meta-layout-2020/mozilla/service-workers/service-worker-registration.https.html.ini index c1810295a29..577ca67b292 100644 --- a/tests/wpt/mozilla/meta-layout-2020/mozilla/service-workers/service-worker-registration.html.ini +++ b/tests/wpt/mozilla/meta-layout-2020/mozilla/service-workers/service-worker-registration.https.html.ini @@ -1,4 +1,4 @@ -[service-worker-registration.html] +[service-worker-registration.https.html] [Test: Throws Error when Invalid Scope] expected: FAIL diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index ecf75a68e87..f68c2ac1e00 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -14273,8 +14273,8 @@ ] ], "service-workers": { - "service-worker-registration.html": [ - "da46088ca92d8706c40a48fdb3805aaf28bbddd5", + "service-worker-registration.https.html": [ + "949992e45de6858c336936b4f1ea4bca76db1d91", [ null, {} diff --git a/tests/wpt/mozilla/tests/mozilla/service-workers/service-worker-registration.html b/tests/wpt/mozilla/tests/mozilla/service-workers/service-worker-registration.https.html similarity index 95% rename from tests/wpt/mozilla/tests/mozilla/service-workers/service-worker-registration.html rename to tests/wpt/mozilla/tests/mozilla/service-workers/service-worker-registration.https.html index da46088ca92..949992e45de 100644 --- a/tests/wpt/mozilla/tests/mozilla/service-workers/service-worker-registration.html +++ b/tests/wpt/mozilla/tests/mozilla/service-workers/service-worker-registration.https.html @@ -16,7 +16,7 @@ test(function (){ 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"); @@ -30,7 +30,7 @@ promise_test(function() { 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");