blob: d48f67a522a2c28307e9acfec14647d15564ab29 [file] [log] [blame]
<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.php?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);
debug(src);
if (expected)
shouldBeTrue("styleSheetContentsShared");
else
shouldBeFalse("styleSheetContentsShared");
completionHandler();
});
});
}
testSharing("shareable.css", true, function () {
testSharing("non-shareable.css", false, function () {
finishJSTest();
});
});
</script>
<script src="../../js-test-resources/js-test-post.js"></script>