Regression(r188105): Seems to have caused crashes during PLT on some iPads
[WebKit-https.git] / LayoutTests / fast / css / import-and-insert-rule-no-update.html
1 <!DOCTYPE html>
2 <html><head>
3 <link rel="stylesheet" href="resources/redimport.css"/>
4 </head><body>
5 <div>Test for bug <a href="https://bugs.webkit.org/show_bug.cgi?id=56981">56981</a>: CSSStyleSheet#insertRule doesn't work well with imported stylesheets</div>
6 <div>You should see one PASS below.</div>
7 <div id="testArea"></div>
8 <script>
9 if (window.testRunner) {
10     testRunner.dumpAsText();
11     testRunner.waitUntilDone();
12 }
13
14 var remainingTests = 20;
15
16 function test() {
17     try {
18         var testArea = document.getElementById("testArea");
19         if (getComputedStyle(testArea).backgroundColor == "rgb(0, 128, 0)") {
20             testArea.innerHTML = 'PASS';
21             remainingTests = 0;
22         } else {
23             if (--remainingTests)
24                 testArea.innerHTML = 'FAIL, backgroundColor was ' + getComputedStyle(testArea).backgroundColor;
25         }
26     } catch (e) {
27         testArea.innerHTML = 'FAIL, exception raised (' + e.message + ')';
28         remainingTests = 0;
29     }
30     if (!remainingTests)
31         window.setTimeout(test, 25);
32     if (window.testRunner)
33         testRunner.notifyDone();
34 }
35
36 function waitForSheetToFinishLoading()
37 {
38     if (document.styleSheets.length && document.styleSheets[0].rules[1].styleSheet) {
39         test();
40         return;
41     }
42
43     window.setTimeout(waitForSheetToFinishLoading, 10)
44 }
45
46 window.onload = function() {
47     document.styleSheets[0].insertRule('@import "green.css";', 1);
48
49     // We need to wait some time to let the stylesheet load before testing.
50     window.setTimeout(waitForSheetToFinishLoading, 10);
51 };
52 </script>
53 </body></html>