blob: 9df0a54b7d8524176a9ff1289f8d4275035d835b [file] [log] [blame]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CSSOM - CSSStylesheet should support origins</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link id="crossorigin" href="http://www1.{{host}}:{{ports[http][1]}}/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">
<script>
var crossorigin = document.getElementById("crossorigin").sheet;
var sameorigin = document.getElementById("sameorigin").sheet;
var sameorigindata = document.getElementById("sameorigindata").sheet;
test(function() {
assert_throws("SecurityError",
function () {
crossorigin.cssRules;
},
"Cross origin stylesheet.cssRules should throw SecurityError.");
assert_throws("SecurityError",
function () {
crossorigin.insertRule("#test { margin: 10px; }", 1);
},
"Cross origin stylesheet.insertRule should throw SecurityError.");
assert_throws("SecurityError",
function () {
crossorigin.deleteRule(0);
},
"Cross origin stylesheet.deleteRule should throw SecurityError.");
}, "Origin-clean check in cross-origin CSSOM Stylesheets");
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.");
}
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>