зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset d03d64716ccd
This commit is contained in:
Родитель
85b73fe20f
Коммит
c40670ab03
|
@ -255,11 +255,7 @@ nsLayoutStatics::Initialize()
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = nsCSSRuleProcessor::Startup();
|
nsCSSRuleProcessor::Startup();
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
NS_ERROR("Could not initialize nsCSSRuleProcessor");
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef MOZ_XUL
|
#ifdef MOZ_XUL
|
||||||
rv = nsXULPopupManager::Init();
|
rv = nsXULPopupManager::Init();
|
||||||
|
@ -314,7 +310,7 @@ nsLayoutStatics::Shutdown()
|
||||||
nsEventListenerManager::Shutdown();
|
nsEventListenerManager::Shutdown();
|
||||||
nsComputedDOMStyle::Shutdown();
|
nsComputedDOMStyle::Shutdown();
|
||||||
CSSLoaderImpl::Shutdown();
|
CSSLoaderImpl::Shutdown();
|
||||||
nsCSSRuleProcessor::Shutdown();
|
nsCSSRuleProcessor::FreeSystemMetrics();
|
||||||
nsTextFrameTextRunCache::Shutdown();
|
nsTextFrameTextRunCache::Shutdown();
|
||||||
nsHTMLDNSPrefetch::Shutdown();
|
nsHTMLDNSPrefetch::Shutdown();
|
||||||
nsCSSRendering::Shutdown();
|
nsCSSRendering::Shutdown();
|
||||||
|
|
|
@ -87,9 +87,6 @@
|
||||||
#include "nsIPrincipal.h"
|
#include "nsIPrincipal.h"
|
||||||
#include "nsStyleSet.h"
|
#include "nsStyleSet.h"
|
||||||
#include "prlog.h"
|
#include "prlog.h"
|
||||||
#include "nsIObserverService.h"
|
|
||||||
#include "nsIPrivateBrowsingService.h"
|
|
||||||
#include "nsNetCID.h"
|
|
||||||
|
|
||||||
#define VISITED_PSEUDO_PREF "layout.css.visited_links_enabled"
|
#define VISITED_PSEUDO_PREF "layout.css.visited_links_enabled"
|
||||||
|
|
||||||
|
@ -771,62 +768,6 @@ RuleCascadeData::AttributeListFor(nsIAtom* aAttribute)
|
||||||
return entry->mSelectors;
|
return entry->mSelectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
class nsPrivateBrowsingObserver : nsIObserver,
|
|
||||||
nsSupportsWeakReference
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
nsPrivateBrowsingObserver();
|
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
NS_DECL_NSIOBSERVER
|
|
||||||
|
|
||||||
void Init();
|
|
||||||
PRBool InPrivateBrowsing() const { return mInPrivateBrowsing; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
PRBool mInPrivateBrowsing;
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS2(nsPrivateBrowsingObserver, nsIObserver, nsISupportsWeakReference)
|
|
||||||
|
|
||||||
nsPrivateBrowsingObserver::nsPrivateBrowsingObserver()
|
|
||||||
: mInPrivateBrowsing(PR_FALSE)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nsPrivateBrowsingObserver::Init()
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIPrivateBrowsingService> pbService =
|
|
||||||
do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
|
|
||||||
if (pbService) {
|
|
||||||
pbService->GetPrivateBrowsingEnabled(&mInPrivateBrowsing);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> observerService =
|
|
||||||
do_GetService("@mozilla.org/observer-service;1");
|
|
||||||
if (observerService) {
|
|
||||||
observerService->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_TRUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsPrivateBrowsingObserver::Observe(nsISupports *aSubject,
|
|
||||||
const char *aTopic,
|
|
||||||
const PRUnichar *aData)
|
|
||||||
{
|
|
||||||
if (!strcmp(aTopic, NS_PRIVATE_BROWSING_SWITCH_TOPIC)) {
|
|
||||||
if (!nsCRT::strcmp(aData, NS_LITERAL_STRING(NS_PRIVATE_BROWSING_ENTER).get())) {
|
|
||||||
mInPrivateBrowsing = PR_TRUE;
|
|
||||||
} else {
|
|
||||||
mInPrivateBrowsing = PR_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static nsPrivateBrowsingObserver *gPrivateBrowsingObserver = nsnull;
|
|
||||||
|
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
// CSS Style rule processor implementation
|
// CSS Style rule processor implementation
|
||||||
//
|
//
|
||||||
|
@ -852,7 +793,7 @@ nsCSSRuleProcessor::~nsCSSRuleProcessor()
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS1(nsCSSRuleProcessor, nsIStyleRuleProcessor)
|
NS_IMPL_ISUPPORTS1(nsCSSRuleProcessor, nsIStyleRuleProcessor)
|
||||||
|
|
||||||
/* static */ nsresult
|
/* static */ void
|
||||||
nsCSSRuleProcessor::Startup()
|
nsCSSRuleProcessor::Startup()
|
||||||
{
|
{
|
||||||
nsContentUtils::AddBoolPrefVarCache(VISITED_PSEUDO_PREF,
|
nsContentUtils::AddBoolPrefVarCache(VISITED_PSEUDO_PREF,
|
||||||
|
@ -860,13 +801,6 @@ nsCSSRuleProcessor::Startup()
|
||||||
// We want to default to true, not false as AddBoolPrefVarCache does.
|
// We want to default to true, not false as AddBoolPrefVarCache does.
|
||||||
gSupportVisitedPseudo =
|
gSupportVisitedPseudo =
|
||||||
nsContentUtils::GetBoolPref(VISITED_PSEUDO_PREF, PR_TRUE);
|
nsContentUtils::GetBoolPref(VISITED_PSEUDO_PREF, PR_TRUE);
|
||||||
|
|
||||||
gPrivateBrowsingObserver = new nsPrivateBrowsingObserver();
|
|
||||||
NS_ENSURE_TRUE(gPrivateBrowsingObserver, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
NS_ADDREF(gPrivateBrowsingObserver);
|
|
||||||
gPrivateBrowsingObserver->Init();
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRBool
|
static PRBool
|
||||||
|
@ -956,13 +890,6 @@ nsCSSRuleProcessor::FreeSystemMetrics()
|
||||||
sSystemMetrics = nsnull;
|
sSystemMetrics = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void
|
|
||||||
nsCSSRuleProcessor::Shutdown()
|
|
||||||
{
|
|
||||||
FreeSystemMetrics();
|
|
||||||
NS_RELEASE(gPrivateBrowsingObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* static */ PRBool
|
/* static */ PRBool
|
||||||
nsCSSRuleProcessor::HasSystemMetric(nsIAtom* aMetric)
|
nsCSSRuleProcessor::HasSystemMetric(nsIAtom* aMetric)
|
||||||
{
|
{
|
||||||
|
@ -1110,9 +1037,7 @@ RuleProcessorData::ContentState()
|
||||||
|
|
||||||
// If we are not supposed to mark visited links as such, be sure to flip the
|
// If we are not supposed to mark visited links as such, be sure to flip the
|
||||||
// bits appropriately.
|
// bits appropriately.
|
||||||
if ((!gSupportVisitedPseudo ||
|
if (!gSupportVisitedPseudo && (mContentState & NS_EVENT_STATE_VISITED)) {
|
||||||
gPrivateBrowsingObserver->InPrivateBrowsing()) &&
|
|
||||||
(mContentState & NS_EVENT_STATE_VISITED)) {
|
|
||||||
mContentState = (mContentState & ~PRUint32(NS_EVENT_STATE_VISITED)) |
|
mContentState = (mContentState & ~PRUint32(NS_EVENT_STATE_VISITED)) |
|
||||||
NS_EVENT_STATE_UNVISITED;
|
NS_EVENT_STATE_UNVISITED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,7 @@ public:
|
||||||
public:
|
public:
|
||||||
nsresult ClearRuleCascades();
|
nsresult ClearRuleCascades();
|
||||||
|
|
||||||
static nsresult Startup();
|
static void Startup();
|
||||||
static void Shutdown();
|
|
||||||
static void FreeSystemMetrics();
|
static void FreeSystemMetrics();
|
||||||
static PRBool HasSystemMetric(nsIAtom* aMetric);
|
static PRBool HasSystemMetric(nsIAtom* aMetric);
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,8 @@ include $(topsrcdir)/config/rules.mk
|
||||||
|
|
||||||
_HTTP_FILES = \
|
_HTTP_FILES = \
|
||||||
visited_page.html \
|
visited_page.html \
|
||||||
|
visited_page-2.html \
|
||||||
|
visited_page-3.html \
|
||||||
link_page.html \
|
link_page.html \
|
||||||
link_page-2.html \
|
link_page-2.html \
|
||||||
link_page-3.html \
|
link_page-3.html \
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Visited page 2</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>This second page is marked as visited</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Visited page 3</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>This third page is marked as visited</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -22,39 +22,6 @@ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
const Cc = Components.classes;
|
const Cc = Components.classes;
|
||||||
const Cr = Components.results;
|
const Cr = Components.results;
|
||||||
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
|
||||||
|
|
||||||
const LAZY_ADD_TIMER = 3000;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function which waits until another function returns true, and
|
|
||||||
* then notifies a callback.
|
|
||||||
*
|
|
||||||
* Original function stolen from docshell/test/chrome/docshell_helpers.js.
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
*
|
|
||||||
* fn: a function which is evaluated repeatedly, and when it turns true,
|
|
||||||
* the onWaitComplete callback is notified.
|
|
||||||
*
|
|
||||||
* onWaitComplete: a callback which will be notified when fn() returns
|
|
||||||
* true.
|
|
||||||
*/
|
|
||||||
function waitForTrue(fn, onWaitComplete) {
|
|
||||||
var start = new Date().valueOf();
|
|
||||||
|
|
||||||
// Loop until the test function returns true, or until a timeout occurs,
|
|
||||||
// if a timeout is defined.
|
|
||||||
var intervalid =
|
|
||||||
setInterval(
|
|
||||||
function() {
|
|
||||||
if (fn.call()) {
|
|
||||||
// Stop calling the test function and notify the callback.
|
|
||||||
clearInterval(intervalid);
|
|
||||||
onWaitComplete.call();
|
|
||||||
}
|
|
||||||
}, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
const kRed = "rgb(255, 0, 0)";
|
const kRed = "rgb(255, 0, 0)";
|
||||||
const kBlue = "rgb(0, 0, 255)";
|
const kBlue = "rgb(0, 0, 255)";
|
||||||
|
@ -63,9 +30,11 @@ var testpath = document.location.pathname + "/../bug_461710/";
|
||||||
var prefix = "http://localhost:8888" + testpath;
|
var prefix = "http://localhost:8888" + testpath;
|
||||||
var subtests = [
|
var subtests = [
|
||||||
"visited_page.html", // 1
|
"visited_page.html", // 1
|
||||||
"link_page.html", // 2
|
"visited_page-2.html", // 2
|
||||||
"link_page-2.html", // 3
|
"visited_page-3.html", // 3
|
||||||
"link_page-3.html" // 4
|
"link_page.html", // 4
|
||||||
|
"link_page-2.html", // 5
|
||||||
|
"link_page-3.html" // 6
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,15 +49,23 @@ function loadNextTest() {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
ok(!pb.privateBrowsingEnabled, "Test #" + testNum + " should be run outside of private mode");
|
// nothing to do here
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
|
// nothing to do here
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
ok(!pb.privateBrowsingEnabled, "Test #" + testNum + " should be run outside of private mode");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
pb.privateBrowsingEnabled = true;
|
pb.privateBrowsingEnabled = true;
|
||||||
ok(pb.privateBrowsingEnabled, "Test #" + testNum + " should be run inside of private mode");
|
ok(pb.privateBrowsingEnabled, "Test #" + testNum + " should be run inside of private mode");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 6:
|
||||||
pb.privateBrowsingEnabled = false;
|
pb.privateBrowsingEnabled = false;
|
||||||
ok(!pb.privateBrowsingEnabled, "Test #" + testNum + " should be run outside of private mode");
|
ok(!pb.privateBrowsingEnabled, "Test #" + testNum + " should be run outside of private mode");
|
||||||
break;
|
break;
|
||||||
|
@ -97,18 +74,6 @@ function loadNextTest() {
|
||||||
ok(false, "Unexpected call to loadNextTest for test #" + testNum);
|
ok(false, "Unexpected call to loadNextTest for test #" + testNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testNum == 1) {
|
|
||||||
// Because of LAZY_ADD, the page won't be marked as visited until three seconds,
|
|
||||||
// so wait for four seconds to be safe
|
|
||||||
setTimeout(handleLoad, LAZY_ADD_TIMER * 2);
|
|
||||||
} else {
|
|
||||||
observer.expectURL(prefix + subtests[0]);
|
|
||||||
waitForTrue(function() observer.resolved, function() {
|
|
||||||
// And the nodes get notified after the "link-visited" topic, so
|
|
||||||
// we need to execute soon...
|
|
||||||
SimpleTest.executeSoon(handleLoad);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
iframe.src = prefix + subtests[testNum-1];
|
iframe.src = prefix + subtests[testNum-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +85,14 @@ function checkTest() {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
// nothing to do here, we just want to mark the page as visited
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
// nothing to do here, we just want to mark the page as visited
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
// run outside of private mode, link should appear as visited
|
// run outside of private mode, link should appear as visited
|
||||||
var doc = iframe.contentDocument;
|
var doc = iframe.contentDocument;
|
||||||
var win = doc.defaultView;
|
var win = doc.defaultView;
|
||||||
|
@ -127,7 +100,7 @@ function checkTest() {
|
||||||
is(style.getPropertyValue("color"), kRed, "Visited link coloring should work outside of private mode");
|
is(style.getPropertyValue("color"), kRed, "Visited link coloring should work outside of private mode");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 5:
|
||||||
// run inside of private mode, link should appear as not visited
|
// run inside of private mode, link should appear as not visited
|
||||||
var doc = iframe.contentDocument;
|
var doc = iframe.contentDocument;
|
||||||
var win = doc.defaultView;
|
var win = doc.defaultView;
|
||||||
|
@ -135,7 +108,7 @@ function checkTest() {
|
||||||
is(style.getPropertyValue("color"), kBlue, "Visited link coloring should not work inside of private mode");
|
is(style.getPropertyValue("color"), kBlue, "Visited link coloring should not work inside of private mode");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 6:
|
||||||
// run outside of private mode, link should appear as visited
|
// run outside of private mode, link should appear as visited
|
||||||
var doc = iframe.contentDocument;
|
var doc = iframe.contentDocument;
|
||||||
var win = doc.defaultView;
|
var win = doc.defaultView;
|
||||||
|
@ -164,7 +137,8 @@ function get_PBSvc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function handleLoad() {
|
var ignoreLoad = false;
|
||||||
|
function handleLoad(aEvent) {
|
||||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||||
|
|
||||||
checkTest();
|
checkTest();
|
||||||
|
@ -177,31 +151,6 @@ function handleLoad() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const URI_VISITED_RESOLUTION_TOPIC = "visited-status-resolution";
|
|
||||||
var os, observer = {
|
|
||||||
uri: null,
|
|
||||||
resolved: true,
|
|
||||||
observe: function (aSubject, aTopic, aData) {
|
|
||||||
SimpleTest.is(aTopic, URI_VISITED_RESOLUTION_TOPIC, "Unexpected topic");
|
|
||||||
|
|
||||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
||||||
|
|
||||||
if (this.uri.equals(aSubject.QueryInterface(Ci.nsIURI))) {
|
|
||||||
this.resolved = true;
|
|
||||||
|
|
||||||
os.removeObserver(this, URI_VISITED_RESOLUTION_TOPIC);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
expectURL: function (url) {
|
|
||||||
ok(this.resolved, "Can't set the expected URL when another is yet to be resolved");
|
|
||||||
this.resolved = false;
|
|
||||||
|
|
||||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
||||||
|
|
||||||
this.uri = NetUtil.newURI(url);
|
|
||||||
os.addObserver(this, URI_VISITED_RESOLUTION_TOPIC, false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var pb = get_PBSvc();
|
var pb = get_PBSvc();
|
||||||
if (!pb) { // Private Browsing might not be available
|
if (!pb) { // Private Browsing might not be available
|
||||||
|
@ -214,10 +163,8 @@ if (!pb) { // Private Browsing might not be available
|
||||||
getService(Ci.nsIPrefBranch);
|
getService(Ci.nsIPrefBranch);
|
||||||
prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||||
|
|
||||||
os = Cc["@mozilla.org/observer-service;1"].
|
|
||||||
getService(Ci.nsIObserverService);
|
|
||||||
|
|
||||||
var iframe = document.getElementById("iframe");
|
var iframe = document.getElementById("iframe");
|
||||||
|
iframe.onload = handleLoad;
|
||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче