test_bug680257.html (1860B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=680257 5 --> 6 <head> 7 <title>Test for Bug 680257</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=680257">Mozilla Bug 680257</a> 13 14 <script type="application/javascript"> 15 16 SimpleTest.waitForExplicitFinish(); 17 18 var popup = window.open("file_bug680257.html"); 19 20 var gTestContinuation = null; 21 function continueAsync() { 22 popup.addEventListener("hashchange", 23 function() { gTestContinuation.next(); }, { once: true }); 24 } 25 26 // The popup will call into popupLoaded() once it loads. 27 function popupLoaded() { 28 // runTests() needs to be called from outside popupLoaded's onload handler. 29 // Otherwise, the navigations we do in runTests won't create new SHEntries. 30 SimpleTest.executeSoon(function() { 31 if (!gTestContinuation) { 32 gTestContinuation = runTests(); 33 } 34 gTestContinuation.next(); 35 }); 36 } 37 38 function* runTests() { 39 checkPopupLinkStyle(false, "Initial"); 40 41 popup.location.hash = "a"; 42 continueAsync(); 43 yield; 44 checkPopupLinkStyle(true, "After setting hash"); 45 46 popup.history.back(); 47 continueAsync(); 48 yield; 49 50 checkPopupLinkStyle(false, "After going back"); 51 52 popup.history.forward(); 53 continueAsync(); 54 yield; 55 checkPopupLinkStyle(true, "After going forward"); 56 57 popup.close(); 58 SimpleTest.finish(); 59 } 60 61 function checkPopupLinkStyle(isTarget, desc) { 62 var link = popup.document.getElementById("a"); 63 var style = popup.getComputedStyle(link); 64 var color = style.getPropertyValue("color"); 65 66 // Color is red if isTarget, black otherwise. 67 if (isTarget) { 68 is(color, "rgb(255, 0, 0)", desc); 69 } else { 70 is(color, "rgb(0, 0, 0)", desc); 71 } 72 } 73 74 </script> 75 </body> 76 </html>