test_non_matching_sheet_media.html (1153B)
1 <!doctype html> 2 <!-- https://bugzilla.mozilla.org/show_bug.cgi?id=1386840 --> 3 <title>Test for Bug 1386840: non-matching media list doesn't block rendering</title> 4 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script> 8 var t = async_test("Test that <link> doesn't block rendering with non-matching media"); 9 var loadFired = false; 10 var scriptExecuted = false; 11 12 function sheetLoaded() { 13 loadFired = true; 14 assert_true(scriptExecuted, "Shouldn't wait for load to execute script"); 15 t.done(); 16 } 17 </script> 18 <!-- 19 NOTE(emilio): This can theoretically race if an HTTP packet boundary with a 20 very long delay came right after the link and before the script. If this 21 ever becomes a problem, the way to fix this is using document.write() as 22 explained in bug 1386840 comment 12. 23 --> 24 <link rel="stylesheet" href="data:text/css,foo {}" media="print" onload="t.step(sheetLoaded)"> 25 <script> 26 t.step(function() { 27 scriptExecuted = true; 28 assert_false(loadFired, "Shouldn't have waited for load"); 29 }); 30 </script>