| <!DOCTYPE html> |
| <title>A link element with rel="webbundle" in no secure context</title> |
| <link |
| rel="help" |
| href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" |
| /> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <body> |
| <link id="link_empty" /> |
| <link id="link_web_bundle_1" rel="webbundle" /> |
| <link id="link_web_bundle_2" rel="webbundle" resources="foo" /> |
| <link id="link_web_bundle_3" rel="webbundle" scopes="bar" /> |
| <script> |
| test(() => { |
| assert_false( |
| "resources" in Element.prototype, |
| "resources must not be defined on Element prototype" |
| ); |
| assert_false( |
| "resources" in HTMLLinkElement.prototype, |
| "resources must not be defined on HTMLLinkElement prototype" |
| ); |
| }, "resources must not be defined on HTMLLinkElement prototype in no secure context"); |
| |
| test(() => { |
| assert_false( |
| "scopes" in Element.prototype, |
| "scopes must not be defined on Element prototype" |
| ); |
| assert_false( |
| "scopes" in HTMLLinkElement.prototype, |
| "scopes must not be defined on HTMLLinkElement prototype" |
| ); |
| }, "scopes must not be defined on HTMLLinkElement prototype in no secure context"); |
| |
| test(() => { |
| const link = document.createElement("link"); |
| assert_false(link.relList.supports("webbundle")); |
| }, "webbundle must not be a supported token of a link element's relList"); |
| |
| test(() => { |
| const link_web_bundle = document.querySelector("#link_web_bundle_1"); |
| assert_equals( |
| link_web_bundle.getAttribute("rel"), |
| "webbundle", |
| "rel attribute must return webbundle" |
| ); |
| assert_true( |
| link_web_bundle.relList.contains("webbundle"), |
| "relList must contain webbundle for <link rel=webbundle>." |
| ); |
| assert_false( |
| document.querySelector("#link_empty").relList.contains("webbundle"), |
| "relList must not contain webbundle for <link>" |
| ); |
| }, "relList must contain webbundle if rel attribute contains it"); |
| |
| test(() => { |
| assert_equals( |
| document.querySelector("#link_web_bundle_1").getAttribute("resources"), |
| null, |
| "resources attribute must return null when the attribute is not given" |
| ); |
| assert_equals( |
| document.querySelector("#link_web_bundle_2").getAttribute("resources"), |
| "foo", |
| "resources attribute must return the specified value" |
| ); |
| assert_equals( |
| document.querySelector("#link_web_bundle_2").getAttribute("scopes"), |
| null, |
| "scopes attribute must return null when the attribute is not given" |
| ); |
| assert_equals( |
| document.querySelector("#link_web_bundle_3").getAttribute("scopes"), |
| "bar", |
| "scopes attribute must return the specified value" |
| ); |
| }, "resoruces and scopes attribute must return null or specified value"); |
| |
| test(() => { |
| const link = document.createElement("link"); |
| assert_equals(link.resources, undefined); |
| }, "resources must be undefined"); |
| |
| test(() => { |
| const link = document.createElement("link"); |
| assert_equals(link.scopes, undefined); |
| }, "scopes must be undefined"); |
| </script> |
| </body> |