Merge mozilla-central to mozilla-inbound

This commit is contained in:
Ed Morley 2012-12-13 16:02:48 +00:00
commit 4d946bd718
15 changed files with 431 additions and 22 deletions

View File

@ -22,6 +22,7 @@
"MOZILLA_OFFICIAL": "1",
"B2GUPDATER": "1"
},
"gecko_l10n_root": "http://hg.mozilla.org/l10n-central",
"gaia": {
"vcs": "hgtool",
"repo": "http://hg.mozilla.org/integration/gaia-nightly",

View File

@ -12,6 +12,7 @@
"{srcdir}/b2g/config/panda/README",
"{workdir}/sources.xml"
],
"gecko_l10n_root": "http://hg.mozilla.org/l10n-central",
"gaia": {
"vcs": "hgtool",
"repo": "http://hg.mozilla.org/integration/gaia-central",

View File

@ -12,6 +12,7 @@
"{srcdir}/b2g/config/panda/README",
"{workdir}/sources.xml"
],
"gecko_l10n_root": "http://hg.mozilla.org/l10n-central",
"gaia": {
"vcs": "hgtool",
"repo": "http://hg.mozilla.org/integration/gaia-nightly",

View File

@ -23,6 +23,7 @@
"MOZILLA_OFFICIAL": "1",
"B2GUPDATER": "1"
},
"gecko_l10n_root": "http://hg.mozilla.org/l10n-central",
"gaia": {
"vcs": "hgtool",
"repo": "http://hg.mozilla.org/integration/gaia-nightly",

View File

@ -351,7 +351,10 @@ XBLEnumerate(JSContext *cx, JS::Handle<JSObject*> obj)
return protoBinding->ResolveAllFields(cx, obj);
}
nsXBLJSClass::nsXBLJSClass(const nsAFlatCString& aClassName)
uint64_t nsXBLJSClass::sIdCount = 0;
nsXBLJSClass::nsXBLJSClass(const nsAFlatCString& aClassName,
const nsCString& aKey)
{
memset(this, 0, sizeof(nsXBLJSClass));
next = prev = static_cast<JSCList*>(this);
@ -367,6 +370,7 @@ nsXBLJSClass::nsXBLJSClass(const nsAFlatCString& aClassName)
resolve = (JSResolveOp)XBLResolve;
convert = ::JS_ConvertStub;
finalize = XBLFinalize;
mKey = aKey;
}
nsrefcnt
@ -376,8 +380,9 @@ nsXBLJSClass::Destroy()
"referenced nsXBLJSClass is on LRU list already!?");
if (nsXBLService::gClassTable) {
nsCStringKey key(name);
nsCStringKey key(mKey);
(nsXBLService::gClassTable)->Remove(&key);
mKey.Truncate();
}
if (nsXBLService::gClassLRUListLength >= nsXBLService::gClassLRUListQuota) {
@ -1357,11 +1362,12 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
{
// First ensure our JS class is initialized.
nsAutoCString className(aClassName);
nsAutoCString xblKey(aClassName);
JSObject* parent_proto = nullptr; // If we have an "obj" we can set this
JSAutoRequest ar(cx);
JSAutoCompartment ac(cx, global);
nsXBLJSClass* c = nullptr;
if (obj) {
// Retrieve the current prototype of obj.
if (!JS_GetPrototype(cx, obj, &parent_proto)) {
@ -1369,7 +1375,7 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
}
if (parent_proto) {
// We need to create a unique classname based on aClassName and
// parent_proto. Append a space (an invalid URI character) to ensure that
// id. Append a space (an invalid URI character) to ensure that
// we don't have accidental collisions with the case when parent_proto is
// null and aClassName ends in some bizarre numbers (yeah, it's unlikely).
jsid parent_proto_id;
@ -1383,8 +1389,23 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
// string representation of what we're printing does not fit in the buffer
// provided).
char buf[20];
PR_snprintf(buf, sizeof(buf), " %lx", parent_proto_id);
className.Append(buf);
if (sizeof(jsid) == 4) {
PR_snprintf(buf, sizeof(buf), " %lx", parent_proto_id);
} else {
MOZ_ASSERT(sizeof(jsid) == 8);
PR_snprintf(buf, sizeof(buf), " %llx", parent_proto_id);
}
xblKey.Append(buf);
nsCStringKey key(xblKey);
c = static_cast<nsXBLJSClass*>(nsXBLService::gClassTable->Get(&key));
if (c) {
className.Assign(c->name);
} else {
char buf[20];
PR_snprintf(buf, sizeof(buf), " %llx", nsXBLJSClass::NewId());
className.Append(buf);
}
}
}
@ -1394,14 +1415,11 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
JSVAL_IS_PRIMITIVE(val)) {
// We need to initialize the class.
nsXBLJSClass* c;
void* classObject;
nsCStringKey key(className);
classObject = (nsXBLService::gClassTable)->Get(&key);
if (classObject) {
c = static_cast<nsXBLJSClass*>(classObject);
nsCStringKey key(xblKey);
if (!c) {
c = static_cast<nsXBLJSClass*>(nsXBLService::gClassTable->Get(&key));
}
if (c) {
// If c is on the LRU list (i.e., not linked to itself), remove it now!
JSCList* link = static_cast<JSCList*>(c);
if (c->next != link) {
@ -1411,7 +1429,7 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
} else {
if (JS_CLIST_IS_EMPTY(&nsXBLService::gClassLRUList)) {
// We need to create a struct for this class.
c = new nsXBLJSClass(className);
c = new nsXBLJSClass(className, xblKey);
if (!c)
return NS_ERROR_OUT_OF_MEMORY;
@ -1423,12 +1441,13 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
// Remove any mapping from the old name to the class struct.
c = static_cast<nsXBLJSClass*>(lru);
nsCStringKey oldKey(c->name);
nsCStringKey oldKey(c->Key());
(nsXBLService::gClassTable)->Remove(&oldKey);
// Change the class name and we're done.
nsMemory::Free((void*) c->name);
c->name = ToNewCString(className);
c->SetKey(xblKey);
}
// Add c to our table.

View File

@ -134,12 +134,19 @@ class nsXBLJSClass : public JSCList, public JSClass
{
private:
nsrefcnt mRefCnt;
nsCString mKey;
static uint64_t sIdCount;
nsrefcnt Destroy();
public:
nsXBLJSClass(const nsAFlatCString& aClassName);
nsXBLJSClass(const nsAFlatCString& aClassName, const nsCString& aKey);
~nsXBLJSClass() { nsMemory::Free((void*) name); }
static uint64_t NewId() { return ++sIdCount; }
nsCString& Key() { return mKey; }
void SetKey(const nsCString& aKey) { mKey = aKey; }
nsrefcnt Hold() { return ++mRefCnt; }
nsrefcnt Drop() { return --mRefCnt ? mRefCnt : Destroy(); }
};

View File

@ -10,10 +10,8 @@ relativesrcdir = @relativesrcdir@
include $(DEPTH)/config/autoconf.mk
# Bug 814718 and bug 818466 prevent us from running the following tests:
# Bug 814718 prevents us from running the following test:
# test_getUserMedia_basicVideo.html
# test_getUserMedia_basicAudio.html
# test_getUserMedia_basicVideoAudio.html
MOCHITEST_FILES = \
test_getUserMedia_exceptions.html \
@ -24,6 +22,8 @@ MOCHITEST_FILES = \
# The following tests are leaking and cannot be run by default yet
ifdef MOZ_WEBRTC_LEAKING_TESTS
MOCHITEST_FILES += \
test_getUserMedia_basicAudio.html \
test_getUserMedia_basicVideoAudio.html \
$(NULL)
endif

View File

@ -19,9 +19,9 @@ function runTest(aCallback, desktopSupportedOnly) {
// If this is a desktop supported test and we're on android or b2g,
// indicate that the test is not supported and skip the test
if(desktopSupportedOnly && (navigator.platform === 'Android' ||
if(desktopSupportedOnly && (navigator.userAgent.indexOf('Android') > -1 ||
navigator.platform === '')) {
ok(true, navigator.platform + ' currently not supported');
ok(true, navigator.userAgent + ' currently not supported');
SimpleTest.finish();
} else {
SpecialPowers.pushPrefEnv({'set': [['media.peerconnection.enabled', true]]},

View File

@ -69,4 +69,11 @@ MOCHITEST_CHROME_FILES = \
frame_clear_browser_data.html \
$(NULL)
ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
MOCHITEST_CHROME_FILES += \
test_localStorageBasePrivateBrowsing_perwindowpb.html \
page_blank.html \
$(NULL)
endif
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,5 @@
<html>
<body>
aaaaaaaaaaaaaaaaaaaa
</body>
</html>

View File

@ -0,0 +1,264 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>localStorage basic test, while in sesison only mode</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<script type="text/javascript">
const Ci = Components.interfaces;
var mainWindow;
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
prefBranch.setIntPref("browser.startup.page", 0);
prefBranch.setCharPref("browser.startup.homepage_override.mstone", "ignore");
function startTest() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
doTest();
}
var contentPage = "http://mochi.test:8888/chrome/dom/tests/mochitest/localstorage/page_blank.html";
function testOnWindow(aIsPrivate, aCallback) {
var win = mainWindow.OpenBrowserWindow({private: aIsPrivate});
win.addEventListener("load", function onLoad() {
win.removeEventListener("load", onLoad, false);
win.addEventListener("DOMContentLoaded", function onInnerLoad() {
// I am at my wits' end figuring out how to stop this load from occurring. I give up.
if (win.content.location.href == "about:privatebrowsing") {
win.gBrowser.loadURI(contentPage);
return;
}
win.removeEventListener("DOMConten/tLoaded", onInnerLoad, true);
SimpleTest.executeSoon(function() { aCallback(win); });
}, true);
win.gBrowser.loadURI(contentPage);
}, true);
}
function doTest() {
testOnWindow(false, function(aWin) {
aWin.content.localStorage.setItem("persistent", "persistent1");
testOnWindow(true, function(privateWin) {
is(privateWin.content.localStorage.getItem("persistent"), null, "previous values are inaccessible");
// Initially check the privateWin.content.localStorage is empty
is(privateWin.content.localStorage.length, 0, "The storage is empty [1]");
is(privateWin.content.localStorage.key(0), null, "key() should return null for out-of-bounds access");
is(privateWin.content.localStorage.key(-1), null, "key() should return null for out-of-bounds access");
is(privateWin.content.localStorage.key(1), null, "key() should return null for out-of-bounds access");
is(privateWin.content.localStorage.getItem("nonexisting"), null, "Nonexisting item is null (getItem())");
is(privateWin.content.localStorage["nonexisting"], undefined, "Nonexisting item is null (array access)");
is(privateWin.content.localStorage.nonexisting, undefined, "Nonexisting item is null (property access)");
privateWin.content.localStorage.removeItem("nonexisting"); // Just check there is no exception
is(typeof privateWin.content.localStorage.getItem("nonexisting"), "object", "getItem('nonexisting') is object");
is(typeof privateWin.content.localStorage["nonexisting"], "undefined", "['nonexisting'] is undefined");
is(typeof privateWin.content.localStorage.nonexisting, "undefined", "nonexisting is undefined");
is(typeof privateWin.content.localStorage.getItem("nonexisting2"), "object", "getItem('nonexisting2') is object");
is(typeof privateWin.content.localStorage["nonexisting2"], "undefined", "['nonexisting2'] is undefined");
is(typeof privateWin.content.localStorage.nonexisting2, "undefined", "nonexisting2 is undefined");
// add an empty-value key
privateWin.content.localStorage.setItem("empty", "");
is(privateWin.content.localStorage.getItem("empty"), "", "Empty value (getItem())");
is(privateWin.content.localStorage["empty"], "", "Empty value (array access)");
is(privateWin.content.localStorage.empty, "", "Empty value (property access)");
is(typeof privateWin.content.localStorage.getItem("empty"), "string", "getItem('empty') is string");
is(typeof privateWin.content.localStorage["empty"], "string", "['empty'] is string");
is(typeof privateWin.content.localStorage.empty, "string", "empty is string");
privateWin.content.localStorage.removeItem("empty");
is(privateWin.content.localStorage.length, 0, "The storage has no keys");
is(privateWin.content.localStorage.getItem("empty"), null, "empty item is null (getItem())");
is(privateWin.content.localStorage["empty"], null, "empty item is undefined (array access)");
is(privateWin.content.localStorage.empty, null, "empty item is undefined (property access)");
is(typeof privateWin.content.localStorage.getItem("empty"), "object", "getItem('empty') is object");
is(typeof privateWin.content.localStorage["empty"], "undefined", "['empty'] is undefined");
is(typeof privateWin.content.localStorage.empty, "undefined", "empty is undefined");
// add one key, check it is there
privateWin.content.localStorage.setItem("key1", "value1");
is(privateWin.content.localStorage.length, 1, "The storage has one key-value pair");
is(privateWin.content.localStorage.key(0), "key1");
is(privateWin.content.localStorage.key(-1), null, "key() should return null for out-of-bounds access");
is(privateWin.content.localStorage.key(1), null, "key() should return null for out-of-bounds access");
// check all access method give the correct result
// and are of the correct type
is(privateWin.content.localStorage.getItem("key1"), "value1", "getItem('key1') == value1");
is(privateWin.content.localStorage["key1"], "value1", "['key1'] == value1");
is(privateWin.content.localStorage.key1, "value1", "key1 == value1");
is(typeof privateWin.content.localStorage.getItem("key1"), "string", "getItem('key1') is string");
is(typeof privateWin.content.localStorage["key1"], "string", "['key1'] is string");
is(typeof privateWin.content.localStorage.key1, "string", "key1 is string");
// remove the previously added key and check the storage is empty
privateWin.content.localStorage.removeItem("key1");
is(privateWin.content.localStorage.length, 0, "The storage is empty [2]");
is(privateWin.content.localStorage.key(0), null, "key() should return null for out-of-bounds access");
is(privateWin.content.localStorage.getItem("key1"), null, "\'key1\' removed");
is(typeof privateWin.content.localStorage.getItem("key1"), "object", "getItem('key1') is object");
is(typeof privateWin.content.localStorage["key1"], "undefined", "['key1'] is undefined");
is(typeof privateWin.content.localStorage.key1, "undefined", "key1 is undefined");
// add one key, check it is there
privateWin.content.localStorage.setItem("key1", "value1");
is(privateWin.content.localStorage.length, 1, "The storage has one key-value pair");
is(privateWin.content.localStorage.key(0), "key1");
is(privateWin.content.localStorage.getItem("key1"), "value1");
// add a second key
privateWin.content.localStorage.setItem("key2", "value2");
is(privateWin.content.localStorage.length, 2, "The storage has two key-value pairs");
is(privateWin.content.localStorage.getItem("key1"), "value1");
is(privateWin.content.localStorage.getItem("key2"), "value2");
var firstKey = privateWin.content.localStorage.key(0);
var secondKey = privateWin.content.localStorage.key(1);
ok((firstKey == 'key1' && secondKey == 'key2') ||
(firstKey == 'key2' && secondKey == 'key1'),
'key() API works.');
// change the second key
privateWin.content.localStorage.setItem("key2", "value2-2");
is(privateWin.content.localStorage.length, 2, "The storage has two key-value pairs");
is(privateWin.content.localStorage.key(0), firstKey); // After key value changes the order must be preserved
is(privateWin.content.localStorage.key(1), secondKey);
is(privateWin.content.localStorage.key(-1), null, "key() should return null for out-of-bounds access");
is(privateWin.content.localStorage.key(2), null, "key() should return null for out-of-bounds access");
is(privateWin.content.localStorage.getItem("key1"), "value1");
is(privateWin.content.localStorage.getItem("key2"), "value2-2");
// change the first key
privateWin.content.localStorage.setItem("key1", "value1-2");
is(privateWin.content.localStorage.length, 2, "The storage has two key-value pairs");
is(privateWin.content.localStorage.key(0), firstKey); // After key value changes the order must be preserved
is(privateWin.content.localStorage.key(1), secondKey);
is(privateWin.content.localStorage.key(-1), null, "key() should return null for out-of-bounds access");
is(privateWin.content.localStorage.key(2), null, "key() should return null for out-of-bounds access");
is(privateWin.content.localStorage.getItem("key1"), "value1-2");
is(privateWin.content.localStorage.getItem("key2"), "value2-2");
// remove the second key
privateWin.content.localStorage.removeItem("key2");
is(privateWin.content.localStorage.length, 1, "The storage has one key-value pair");
is(privateWin.content.localStorage.key(0), "key1");
is(privateWin.content.localStorage.key(-1), null, "key() should return null for out-of-bounds access");
is(privateWin.content.localStorage.key(1), null, "key() should return null for out-of-bounds access");
is(privateWin.content.localStorage.getItem("key1"), "value1-2");
// JS property test
privateWin.content.localStorage.testA = "valueA";
is(privateWin.content.localStorage.testA, "valueA");
is(privateWin.content.localStorage["testA"], "valueA");
is(privateWin.content.localStorage.getItem("testA"), "valueA");
privateWin.content.localStorage.testA = "valueA2";
is(privateWin.content.localStorage.testA, "valueA2");
is(privateWin.content.localStorage["testA"], "valueA2");
is(privateWin.content.localStorage.getItem("testA"), "valueA2");
privateWin.content.localStorage["testB"] = "valueB";
is(privateWin.content.localStorage.testB, "valueB");
is(privateWin.content.localStorage["testB"], "valueB");
is(privateWin.content.localStorage.getItem("testB"), "valueB");
privateWin.content.localStorage["testB"] = "valueB2";
is(privateWin.content.localStorage.testB, "valueB2");
is(privateWin.content.localStorage["testB"], "valueB2");
is(privateWin.content.localStorage.getItem("testB"), "valueB2");
privateWin.content.localStorage.setItem("testC", "valueC");
is(privateWin.content.localStorage.testC, "valueC");
is(privateWin.content.localStorage["testC"], "valueC");
is(privateWin.content.localStorage.getItem("testC"), "valueC");
privateWin.content.localStorage.setItem("testC", "valueC2");
is(privateWin.content.localStorage.testC, "valueC2");
is(privateWin.content.localStorage["testC"], "valueC2");
is(privateWin.content.localStorage.getItem("testC"), "valueC2");
privateWin.content.localStorage.setItem("testC", null);
is("testC" in privateWin.content.localStorage, true);
is(privateWin.content.localStorage.getItem("testC"), "null");
is(privateWin.content.localStorage["testC"], "null");
is(privateWin.content.localStorage.testC, "null");
privateWin.content.localStorage.removeItem("testC");
privateWin.content.localStorage["testC"] = null;
is("testC" in privateWin.content.localStorage, true);
is(privateWin.content.localStorage.getItem("testC"), "null");
is(privateWin.content.localStorage["testC"], "null");
is(privateWin.content.localStorage.testC, "null");
privateWin.content.localStorage.setItem(null, "test");
is("null" in privateWin.content.localStorage, true);
is(privateWin.content.localStorage.getItem("null"), "test");
is(privateWin.content.localStorage.getItem(null), "test");
is(privateWin.content.localStorage["null"], "test");
privateWin.content.localStorage.removeItem(null, "test");
// bug 350023
todo_is("null" in privateWin.content.localStorage, false);
privateWin.content.localStorage.setItem(null, "test");
is("null" in privateWin.content.localStorage, true);
privateWin.content.localStorage.removeItem("null", "test");
// bug 350023
todo_is("null" in privateWin.content.localStorage, false);
// Clear the storage
privateWin.content.localStorage.clear();
is(privateWin.content.localStorage.length, 0, "The storage is empty [3]");
is(privateWin.content.localStorage.key(0), null, "key() should return null for out-of-bounds access");
is(privateWin.content.localStorage.key(-1), null, "key() should return null for out-of-bounds access");
is(privateWin.content.localStorage.key(1), null, "key() should return null for out-of-bounds access");
is(privateWin.content.localStorage.getItem("nonexisting"), null, "Nonexisting item is null");
is(privateWin.content.localStorage.getItem("key1"), null, "key1 removed");
is(privateWin.content.localStorage.getItem("key2"), null, "key2 removed");
privateWin.content.localStorage.removeItem("nonexisting"); // Just check there is no exception
privateWin.content.localStorage.removeItem("key1"); // Just check there is no exception
privateWin.content.localStorage.removeItem("key2"); // Just check there is no exception
privateWin.content.localStorage.setItem("must disappear", "private browsing value");
privateWin.close();
testOnWindow(true, function(newPrivateWin) {
is(newPrivateWin.content.localStorage.getItem("must disappear"), null, "private browsing values threw away");
is(newPrivateWin.content.localStorage.length, 0, "No items");
newPrivateWin.close();
is(aWin.content.localStorage.getItem("persistent"), "persistent1", "back in normal mode");
aWin.content.localStorage.clear();
aWin.close();
prefBranch.clearUserPref("browser.startup.page")
prefBranch.clearUserPref("browser.startup.homepage_override.mstone");
SimpleTest.finish();
});
});
});
}
SimpleTest.waitForExplicitFinish();
</script>
</head>
<body onload="startTest();">
</body>
</html>

View File

@ -10,6 +10,7 @@ VPATH = @srcdir@
MODULE = pipnss
DIRS = \
browser \
bugs \
mixedcontent \
stricttransportsecurity \

View File

@ -0,0 +1,24 @@
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEPTH = @DEPTH@
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = @relativesrcdir@
include $(DEPTH)/config/autoconf.mk
MOCHITEST_BROWSER_FILES = \
head.js \
$(NULL)
ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
MOCHITEST_BROWSER_FILES += \
browser_bug627234_perwindowpb.js \
$(NULL)
endif
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,69 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// This is a template to help porting global private browsing tests
// to per-window private browsing tests
function test() {
// initialization
waitForExplicitFinish();
let windowsToClose = [];
let testURI = "about:blank";
let uri;
let gSTSService = Cc["@mozilla.org/stsservice;1"].
getService(Ci.nsIStrictTransportSecurityService);
function privacyFlags(aIsPrivateMode) {
return aIsPrivateMode ? Ci.nsISocketProvider.NO_PERMANENT_STORAGE : 0;
}
function doTest(aIsPrivateMode, aWindow, aCallback) {
aWindow.gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
aWindow.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
uri = aWindow.Services.io.newURI("https://localhost/img.png", null, null);
gSTSService.processStsHeader(uri, "max-age=1000", privacyFlags(aIsPrivateMode));
ok(gSTSService.isStsHost("localhost", privacyFlags(aIsPrivateMode)), "checking sts host");
aCallback();
}, true);
aWindow.gBrowser.selectedBrowser.loadURI(testURI);
}
function testOnWindow(aOptions, aCallback) {
whenNewWindowLoaded(aOptions, function(aWin) {
windowsToClose.push(aWin);
// execute should only be called when need, like when you are opening
// web pages on the test. If calling executeSoon() is not necesary, then
// call whenNewWindowLoaded() instead of testOnWindow() on your test.
executeSoon(function() aCallback(aWin));
});
};
// this function is called after calling finish() on the test.
registerCleanupFunction(function() {
windowsToClose.forEach(function(aWin) {
aWin.close();
});
uri = Services.io.newURI("http://localhost", null, null);
gSTSService.removeStsState(uri, privacyFlags(true));
});
// test first when on private mode
testOnWindow({private: true}, function(aWin) {
doTest(true, aWin, function() {
//test when not on private mode
testOnWindow({}, function(aWin) {
doTest(false, aWin, function() {
//test again when on private mode
testOnWindow({private: true}, function(aWin) {
doTest(true, aWin, function () {
finish();
});
});
});
});
});
});
}

View File

@ -0,0 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function whenNewWindowLoaded(aOptions, aCallback) {
let win = OpenBrowserWindow(aOptions);
win.addEventListener("load", function onLoad() {
win.removeEventListener("load", onLoad, false);
aCallback(win);
}, false);
}