mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Add mochitests for getComputedStyle and querySelector(All) lying about :visited selectors. (Bug 147777)
This commit is contained in:
parent
13e72332b4
commit
0c9f4d1933
@ -176,6 +176,7 @@ _TEST_FILES = test_acid3_test46.html \
|
||||
test_value_cloning.html \
|
||||
test_value_computation.html \
|
||||
test_value_storage.html \
|
||||
test_visited_lying.html \
|
||||
test_visited_pref.html \
|
||||
test_visited_reftests.html \
|
||||
css_properties.js \
|
||||
@ -202,6 +203,7 @@ _TEST_FILES = test_acid3_test46.html \
|
||||
ccd-standards.html \
|
||||
ccd.sjs \
|
||||
visited-pref-iframe.html \
|
||||
visited-lying-inner.html \
|
||||
$(NULL)
|
||||
|
||||
_VISITED_REFTEST_FILES = \
|
||||
|
97
layout/style/test/test_visited_lying.html
Normal file
97
layout/style/test/test_visited_lying.html
Normal file
@ -0,0 +1,97 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=147777
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 147777</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=147777">Mozilla Bug 147777</a>
|
||||
<iframe id="iframe" src="visited-lying-inner.html" style="width: 20em; height: 5em"></iframe>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 147777 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
window.addEventListener("load", start, false);
|
||||
|
||||
var iframe;
|
||||
var visitedlink, unvisitedlink;
|
||||
var snapshot1;
|
||||
|
||||
function start()
|
||||
{
|
||||
// Our load event has fired, so we know our iframe is loaded.
|
||||
iframe = document.getElementById("iframe");
|
||||
visitedlink = iframe.contentDocument.getElementById("visitedlink");
|
||||
unvisitedlink = iframe.contentDocument.getElementById("unvisitedlink");
|
||||
|
||||
// First, take a snapshot of it with both links unvisited.
|
||||
snapshot1 = snapshotWindow(iframe.contentWindow, false);
|
||||
|
||||
// Then, change one of the links in the iframe to being visited.
|
||||
visitedlink.href = window.location;
|
||||
|
||||
// Then, start polling to see when the history has updated the display.
|
||||
setTimeout(poll_for_restyle, 100);
|
||||
}
|
||||
|
||||
function poll_for_restyle()
|
||||
{
|
||||
var snapshot2 = snapshotWindow(iframe.contentWindow, false);
|
||||
var equal = compareSnapshots(snapshot1, snapshot2, true)[0];
|
||||
if (equal) {
|
||||
// keep polling
|
||||
setTimeout(poll_for_restyle, 100);
|
||||
} else {
|
||||
// We now know that the link is visited, so we're ready to run
|
||||
// tests.
|
||||
run_tests();
|
||||
}
|
||||
}
|
||||
|
||||
function run_tests()
|
||||
{
|
||||
// Test querySelector and querySelectorAll.
|
||||
var subdoc = iframe.contentDocument;
|
||||
is(subdoc.querySelector(":link"), unvisitedlink,
|
||||
"first :link should be the unvisited link");
|
||||
is(subdoc.querySelector(":visited"), null,
|
||||
"querySelector should not find anything :visited");
|
||||
var qsr = subdoc.querySelectorAll(":link");
|
||||
is(qsr.length, 2, "querySelectorAll(:link) should find 2 results");
|
||||
is(qsr[0], unvisitedlink, "querySelectorAll(:link)[0]");
|
||||
is(qsr[1], visitedlink, "querySelectorAll(:link)[1]");
|
||||
qsr = subdoc.querySelectorAll(":visited");
|
||||
is(qsr.length, 0, "querySelectorAll(:visited) should find 0 results");
|
||||
|
||||
// Test getComputedStyle.
|
||||
var subwin = iframe.contentWindow;
|
||||
is(subwin.getComputedStyle(unvisitedlink, "").color, "rgb(0, 0, 255)",
|
||||
"getComputedStyle on unvisited link should report color is blue");
|
||||
is(subwin.getComputedStyle(visitedlink, "").color, "rgb(0, 0, 255)",
|
||||
"getComputedStyle on visited link should report color is blue");
|
||||
|
||||
// Test mozMatchesSelector.
|
||||
is(unvisitedlink.mozMatchesSelector(":link"), true,
|
||||
"unvisited link matches :link");
|
||||
is(visitedlink.mozMatchesSelector(":link"), true,
|
||||
"visited link matches :link");
|
||||
is(unvisitedlink.mozMatchesSelector(":visited"), false,
|
||||
"unvisited link does not match :visited");
|
||||
is(visitedlink.mozMatchesSelector(":visited"), false,
|
||||
"visited link does not match :visited");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
8
layout/style/test/visited-lying-inner.html
Normal file
8
layout/style/test/visited-lying-inner.html
Normal file
@ -0,0 +1,8 @@
|
||||
<!DOCTYPE HTML>
|
||||
<title>Test document for test_visited_lying.html</title>
|
||||
<style>
|
||||
:link { color: blue }
|
||||
:visited { color: purple }
|
||||
</style>
|
||||
<div><a id="unvisitedlink" href="http://www.example.com/url-that-was-never-visited">unvisited link</a></div>
|
||||
<div><a id="visitedlink" href="http://www.example.com/url-that-was-never-visited">visited link</a></div>
|
Loading…
Reference in New Issue
Block a user