From 7a857e9b5add3764cbd1ccdd899601c2944d34cb Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Fri, 2 Apr 2010 18:58:25 -0700 Subject: [PATCH] Fix existing tests to deal with getComputedStyle lying about :link vs. :visited. (Bug 147777) r=sdwilsh --- .../html/content/test/test_bug209275.xhtml | 13 ++- .../html/content/test/test_bug481335.xhtml | 12 ++- docshell/test/chrome/bug293235.html | 4 +- docshell/test/chrome/bug293235_window.xul | 25 +++-- .../mochitest/whatwg/test_bug500328.html | 6 +- layout/style/test/Makefile.in | 1 + layout/style/test/test_visited_pref.html | 96 +++++++++++++------ layout/style/test/visited-pref-iframe.html | 7 ++ .../tests/mochitest/test_bug_461710.html | 16 ++-- 9 files changed, 129 insertions(+), 51 deletions(-) create mode 100644 layout/style/test/visited-pref-iframe.html diff --git a/content/html/content/test/test_bug209275.xhtml b/content/html/content/test/test_bug209275.xhtml index 37981a194a84..ef53e897bf68 100644 --- a/content/html/content/test/test_bug209275.xhtml +++ b/content/html/content/test/test_bug209275.xhtml @@ -77,14 +77,19 @@ function link123HrefIs(href, testNum) { var gGen; +function visitedDependentComputedStyle(win, elem, property) { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var utils = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor). + getInterface(Components.interfaces.nsIDOMWindowUtils); + return utils.getVisitedDependentComputedStyle(elem, "", property); +} + function getColor(elem) { - return document.defaultView.getComputedStyle(elem, "").color; + return visitedDependentComputedStyle(document.defaultView, elem, "color"); } function getFill(elem) { - return document.defaultView - .getComputedStyle(elem, "") - .getPropertyValue("fill"); + return visitedDependentComputedStyle(document.defaultView, elem, "fill"); } function setXlinkHref(elem, href) { diff --git a/content/html/content/test/test_bug481335.xhtml b/content/html/content/test/test_bug481335.xhtml index 1a0e290d99ff..525ff0e11e5a 100644 --- a/content/html/content/test/test_bug481335.xhtml +++ b/content/html/content/test/test_bug481335.xhtml @@ -51,12 +51,18 @@ function continueTest() { function checkLinkColor(aElmId, aExpectedColor, aMessage) { // Because link coloring is asynchronous, we wait until we get the right // result, or we will time out (resulting in a failure). - var getCS = document.defaultView.getComputedStyle; - while (getCS($(aElmId), "").color != aExpectedColor) { + function getColor() { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var utils = document.defaultView. + QueryInterface(Components.interfaces.nsIInterfaceRequestor). + getInterface(Components.interfaces.nsIDOMWindowUtils); + return utils.getVisitedDependentComputedStyle($(aElmId), "", "color"); + } + while (getColor() != aExpectedColor) { setTimeout(continueTest, 10); return false; } - is(getCS($(aElmId), "").color, aExpectedColor, aMessage); + is(getColor(), aExpectedColor, aMessage); return true; } diff --git a/docshell/test/chrome/bug293235.html b/docshell/test/chrome/bug293235.html index 4921feb4a779..458f88431c29 100644 --- a/docshell/test/chrome/bug293235.html +++ b/docshell/test/chrome/bug293235.html @@ -2,8 +2,8 @@ Bug 293235 page1 diff --git a/docshell/test/chrome/bug293235_window.xul b/docshell/test/chrome/bug293235_window.xul index 8f1d6947dcde..eddc3d0d8f80 100644 --- a/docshell/test/chrome/bug293235_window.xul +++ b/docshell/test/chrome/bug293235_window.xul @@ -12,6 +12,7 @@ src= "chrome://mochikit/content/chrome/docshell/test/chrome/docshell_helpers.js"> + + +link diff --git a/toolkit/components/places/tests/mochitest/test_bug_461710.html b/toolkit/components/places/tests/mochitest/test_bug_461710.html index 39ca52941392..12ff91b38cd4 100644 --- a/toolkit/components/places/tests/mochitest/test_bug_461710.html +++ b/toolkit/components/places/tests/mochitest/test_bug_461710.html @@ -112,6 +112,13 @@ function loadNextTest() { iframe.src = prefix + subtests[testNum-1]; } +function getColor(doc, win, id) { + var elem = doc.getElementById(id); + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var utils = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor). + getInterface(Components.interfaces.nsIDOMWindowUtils); + return utils.getVisitedDependentComputedStyle(elem, "", "color"); +} function checkTest() { switch (testNum) { @@ -123,24 +130,21 @@ function checkTest() { // run outside of private mode, link should appear as visited var doc = iframe.contentDocument; var win = doc.defaultView; - var style = win.getComputedStyle(doc.getElementById("link"), ""); - is(style.getPropertyValue("color"), kRed, "Visited link coloring should work outside of private mode"); + is(getColor(doc, win, "link"), kRed, "Visited link coloring should work outside of private mode"); break; case 3: // run inside of private mode, link should appear as not visited var doc = iframe.contentDocument; var win = doc.defaultView; - var style = win.getComputedStyle(doc.getElementById("link"), ""); - is(style.getPropertyValue("color"), kBlue, "Visited link coloring should not work inside of private mode"); + is(getColor(doc, win, "link"), kBlue, "Visited link coloring should not work inside of private mode"); break; case 4: // run outside of private mode, link should appear as visited var doc = iframe.contentDocument; var win = doc.defaultView; - var style = win.getComputedStyle(doc.getElementById("link"), ""); - is(style.getPropertyValue("color"), kRed, "Visited link coloring should work outside of private mode"); + is(getColor(doc, win, "link"), kRed, "Visited link coloring should work outside of private mode"); break; default: