layout/style/test/test_visited_lying.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=147777
     5 -->
     6 <head>
     7   <title>Test for Bug 147777</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=147777">Mozilla Bug 147777</a>
    14 <iframe id="iframe" src="visited-lying-inner.html" style="width: 20em; height: 5em"></iframe>
    15 <pre id="test">
    16 <script type="application/javascript">
    18 /** Test for Bug 147777 **/
    20 SimpleTest.waitForExplicitFinish();
    21 window.addEventListener("load", start, false);
    23 var iframe;
    24 var visitedlink, unvisitedlink;
    25 var snapshot1;
    27 function start()
    28 {
    29   // Our load event has fired, so we know our iframe is loaded.
    30   iframe = document.getElementById("iframe");
    31   visitedlink = iframe.contentDocument.getElementById("visitedlink");
    32   unvisitedlink = iframe.contentDocument.getElementById("unvisitedlink");
    34   // First, take a snapshot of it with both links unvisited.
    35   snapshot1 = snapshotWindow(iframe.contentWindow, false);
    37   // Then, change one of the links in the iframe to being visited.
    38   visitedlink.href = window.location;
    40   // Then, start polling to see when the history has updated the display.
    41   setTimeout(poll_for_restyle, 100);
    42 }
    44 function poll_for_restyle()
    45 {
    46   var snapshot2 = snapshotWindow(iframe.contentWindow, false);
    47   var equal = compareSnapshots(snapshot1, snapshot2, true)[0];
    48   if (equal) {
    49     // keep polling
    50     setTimeout(poll_for_restyle, 100);
    51   } else {
    52     // We now know that the link is visited, so we're ready to run
    53     // tests.
    54     run_tests();
    55   }
    56 }
    58 function run_tests()
    59 {
    60   // Test querySelector and querySelectorAll.
    61   var subdoc = iframe.contentDocument;
    62   is(subdoc.querySelector(":link"), unvisitedlink,
    63      "first :link should be the unvisited link");
    64   is(subdoc.querySelector(":visited"), null,
    65      "querySelector should not find anything :visited");
    66   var qsr = subdoc.querySelectorAll(":link");
    67   is(qsr.length, 2, "querySelectorAll(:link) should find 2 results");
    68   is(qsr[0], unvisitedlink, "querySelectorAll(:link)[0]");
    69   is(qsr[1], visitedlink, "querySelectorAll(:link)[1]");
    70   qsr = subdoc.querySelectorAll(":visited");
    71   is(qsr.length, 0, "querySelectorAll(:visited) should find 0 results");
    73   // Test getComputedStyle.
    74   var subwin = iframe.contentWindow;
    75   is(subwin.getComputedStyle(unvisitedlink, "").color, "rgb(0, 0, 255)",
    76      "getComputedStyle on unvisited link should report color is blue");
    77   is(subwin.getComputedStyle(visitedlink, "").color, "rgb(0, 0, 255)",
    78      "getComputedStyle on visited link should report color is blue");
    80   // Test mozMatchesSelector.
    81   is(unvisitedlink.mozMatchesSelector(":link"), true,
    82      "unvisited link matches :link");
    83   is(visitedlink.mozMatchesSelector(":link"), true,
    84      "visited link matches :link");
    85   is(unvisitedlink.mozMatchesSelector(":visited"), false,
    86      "unvisited link does not match :visited");
    87   is(visitedlink.mozMatchesSelector(":visited"), false,
    88      "visited link does not match :visited");
    90   SimpleTest.finish();
    91 }
    93 </script>
    94 </pre>
    95 </body>
    96 </html>

mercurial