diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/css/cssom/stylesheet-same-origin.sub.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/cssom/stylesheet-same-origin.sub.html')
-rw-r--r-- | testing/web-platform/tests/css/cssom/stylesheet-same-origin.sub.html | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/cssom/stylesheet-same-origin.sub.html b/testing/web-platform/tests/css/cssom/stylesheet-same-origin.sub.html new file mode 100644 index 0000000000..6ad55190da --- /dev/null +++ b/testing/web-platform/tests/css/cssom/stylesheet-same-origin.sub.html @@ -0,0 +1,83 @@ +<!doctype html> +<html> +<head> + <meta charset="utf-8"> + <title>CSSOM - CSSStylesheet should support origins</title> + <link rel="help" href="https://drafts.csswg.org/cssom/#the-cssstylesheet-interface"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + + <link id="crossorigin" href="http://www1.{{host}}:{{ports[http][1]}}/css/cssom/stylesheet-same-origin.css" rel="stylesheet"> + <link id="sameorigin" href="stylesheet-same-origin.css" rel="stylesheet"> + <link id="sameorigindata" href="data:text/css,.green-text{color:rgb(0, 255, 0)}" rel="stylesheet"> + <link id="redirect-sameorigin-to-crossorigin" + href="/common/redirect.py?location=http://www1.{{host}}:{{ports[http][1]}}/css/cssom/stylesheet-same-origin.css" + rel="stylesheet"> + <link id="redirect-crossorigin-to-sameorigin" + href="http://www1.{{host}}:{{ports[http][1]}}/common/redirect.py?location=http://{{host}}:{{ports[http][0]}}/css/cssom/stylesheet-same-origin.css" + rel="stylesheet"> + <link id="loaderror" href="support/malformed-http-response.asis" rel="stylesheet"> + + <script> + var crossorigin = document.getElementById("crossorigin").sheet; + var redirectSameOriginToCrossOrigin = document.getElementById("redirect-sameorigin-to-crossorigin").sheet; + var redirectCrossOriginToSameOrigin = document.getElementById("redirect-crossorigin-to-sameorigin").sheet; + var loadError = document.getElementById("loaderror").sheet; + var sameorigin = document.getElementById("sameorigin").sheet; + var sameorigindata = document.getElementById("sameorigindata").sheet; + + function doOriginCleanCheck(sheet, name) { + assert_equals(sheet.cssRules.length, 1, name + " stylesheet.cssRules should be accessible."); + sheet.insertRule("#test { margin: 10px; }", 1); + assert_equals(sheet.cssRules.length, 2, name + " stylesheet.insertRule should be accessible."); + sheet.deleteRule(0); + assert_equals(sheet.cssRules.length, 1, name + " stylesheet.deleteRule should be accessible."); + } + + function doOriginDirtyCheck(sheet) { + assert_throws_dom("SecurityError", + function () { + sheet.cssRules; + }, + 'stylesheet.cssRules should throw SecurityError.'); + assert_throws_dom("SecurityError", + function () { + sheet.insertRule("#test { margin: 10px; }", 1); + }, + 'stylesheet.insertRule should throw SecurityError.'); + + assert_throws_dom("SecurityError", + function () { + sheet.deleteRule(0); + }, + 'stylesheet.deleteRule should throw SecurityError.'); + } + + test(function() { + doOriginDirtyCheck(crossorigin); + }, "Origin-clean check in cross-origin CSSOM Stylesheets"); + + test(function() { + doOriginDirtyCheck(redirectSameOriginToCrossOrigin); + }, "Origin-clean check in cross-origin CSSOM Stylesheets (redirect from same-origin to cross-origin)"); + + test(function() { + doOriginDirtyCheck(redirectCrossOriginToSameOrigin); + }, "Origin-clean check in cross-origin CSSOM Stylesheets (redirect from cross-origin to same-origin)"); + + test(function() { + doOriginDirtyCheck(loadError); + }, "Origin-clean check in loading error CSSOM Stylesheets"); + + test(function() { + doOriginCleanCheck(sameorigin, "Same-origin"); + }, "Origin-clean check in same-origin CSSOM Stylesheets"); + + test(function() { + doOriginCleanCheck(sameorigindata, "data:css"); + }, "Origin-clean check in data:css CSSOM Stylesheets"); + + </script> +</head> +<body> +</html> |