| Index: LayoutTests/http/tests/security/resources/link-crossorigin-common.js
|
| diff --git a/LayoutTests/http/tests/security/resources/link-crossorigin-common.js b/LayoutTests/http/tests/security/resources/link-crossorigin-common.js
|
| index a7f1bdfc2e8b5b750cb054ce9cbed28af0feb441..a50b3a57bec4aadec0a8b8183026dbd0d09928b6 100644
|
| --- a/LayoutTests/http/tests/security/resources/link-crossorigin-common.js
|
| +++ b/LayoutTests/http/tests/security/resources/link-crossorigin-common.js
|
| @@ -1,7 +1,7 @@
|
| // Tiny test rig for all security/link-crossorigin-*.html tests,
|
| // which exercise <link> + CORS variations.
|
|
|
| -self.jsTestIsAsync = true;
|
| +window.jsTestIsAsync = true;
|
|
|
| if (window.testRunner) {
|
| testRunner.dumpAsText();
|
| @@ -9,20 +9,49 @@ if (window.testRunner) {
|
| }
|
|
|
| // The common case is to have four sub-tests. To override
|
| -// for a test, assign window.test_count.
|
| -var default_test_count = 4;
|
| +// for a test, assign window.testCount.
|
| +var defaultTestCount = 4;
|
|
|
| -var event_count = 0;
|
| -test_count = window.test_count || default_test_count;
|
| +var eventCount = 0;
|
| +testCount = window.testCount || defaultTestCount;
|
|
|
| -function finish(pass, msg) {
|
| +function finish(pass, msg, event) {
|
| if (pass)
|
| testPassed(msg || "");
|
| - else
|
| + else
|
| testFailed(msg || "");
|
| - if (++event_count >= test_count)
|
| +
|
| + // Verify that the stylesheet is (in)accessible.
|
| + // (only report failures so as to avoid subtest ordering instability.)
|
| + if (event !== undefined && event.target && event.target.rel === "stylesheet") {
|
| + for (var i = 0; i < document.styleSheets.length; ++i) {
|
| + if (document.styleSheets[i].href !== event.target.href)
|
| + continue;
|
| + if (event.type === "load") {
|
| + try {
|
| + if (document.styleSheets[i].cssRules[0].cssText.length >= 0)
|
| + ;
|
| + if (document.styleSheets[i].cssRules[0].cssText.indexOf("green") == -1)
|
| + testFailed("Failed to find occurrence of 'green' in stylesheet: " + event.target.href);
|
| + } catch (e) {
|
| + testFailed("Failed to access contents of stylesheet: " + event.target.href);
|
| + }
|
| + } else {
|
| + try {
|
| + // Will throw as .cssRules should return 0.
|
| + if (document.styleSheets[i].cssRules[0].cssRules[0])
|
| + ;
|
| + testFailed("Should not be able to access contents of stylesheet: " + event.target.href);
|
| + } catch (e) {
|
| + ;
|
| + }
|
| + }
|
| + break;
|
| + }
|
| + }
|
| + if (++eventCount >= testCount)
|
| finishJSTest();
|
| }
|
|
|
| -function pass() { finish(true); }
|
| -function fail() { finish(false); }
|
| +function pass(event) { finish(true, "", event); }
|
| +function fail(event) { finish(false, "", event); }
|
|
|