test_import_preload.html (857B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <script src="/tests/SimpleTest/SimpleTest.js"></script> 4 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> 5 <script src="slow_load.sjs"></script> 6 <script> 7 let time = Date.now(); 8 SimpleTest.waitForExplicitFinish(); 9 10 onload = function() { 11 let styleTime = parseInt(getComputedStyle(document.documentElement).zIndex, 10); 12 isnot(styleTime, 0, "Should apply the @import sheet"); 13 ok(!isNaN(styleTime), "Should apply the @import sheet (and not be nan)"); 14 // This is technically a bit racy... Also see the comment in slow_load.sjs about the clamping. 15 time = time % (Math.pow(2, 31) - 1); 16 ok(styleTime < time, "Should try to fetch the import before running the script: " + styleTime + " vs. " + time); 17 SimpleTest.finish(); 18 } 19 </script> 20 <style> 21 @import url(slow_load.sjs?css) 22 </style>