| <script src="../../js-test-resources/js-test-pre.js"></script> | |
| <body> | |
| <script> | |
| jsTestIsAsync = true; | |
| function waitForStylesheet(iframe, completionHandler) | |
| { | |
| var link = iframe.contentDocument.getElementsByTagName('link')[0]; | |
| if (internals.isStyleSheetLoadingSubresources(link)) { | |
| setTimeout(function () { waitForStylesheet(iframe, completionHandler) }, 10); | |
| return; | |
| } | |
| completionHandler(link); | |
| } | |
| function load(src, completionHandler) | |
| { | |
| var iframe = document.createElement("iframe"); | |
| iframe.src = "resources/stylesheet-html.py?sheet=" + src; | |
| iframe.onload = function () { | |
| iframe.contentDocument.body.offsetWidth; | |
| waitForStylesheet(iframe, completionHandler); | |
| }; | |
| document.body.appendChild(iframe); | |
| } | |
| function testSharing(src, expected, completionHandler) | |
| { | |
| load(src, function (linkA) { | |
| load(src, function (linkB) { | |
| styleSheetContentsShared = internals.isSharingStyleSheetContents(linkA, linkB); | |
| sheetB = linkB.sheet; | |
| debug(src); | |
| if (expected) | |
| shouldBeTrue("styleSheetContentsShared"); | |
| else | |
| shouldBeFalse("styleSheetContentsShared"); | |
| completionHandler(); | |
| }); | |
| }); | |
| } | |
| testSharing("shareable.css", true, function () { | |
| testSharing("non-shareable.css", false, function () { | |
| testSharing("http://localhost:8000/cache/resources/shareable.css", true, function () { | |
| shouldThrowErrorName("sheetB.cssRules", "SecurityError"); | |
| finishJSTest(); | |
| }); | |
| }); | |
| }); | |
| </script> | |
| <script src="../../js-test-resources/js-test-post.js"></script> |