2012-12-06 18:13:15 -08:00
|
|
|
function test() {
|
|
|
|
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
|
|
|
|
let baseProvider = "http://mochi.test:8888/browser/dom/tests/browser/network_geolocation.sjs";
|
|
|
|
prefs.setCharPref("geo.wifi.uri", baseProvider + "?desired_access_token=fff");
|
|
|
|
|
|
|
|
prefs.setBoolPref("geo.prompt.testing", true);
|
|
|
|
prefs.setBoolPref("geo.prompt.testing.allow", true);
|
|
|
|
|
|
|
|
const testPageURL = "http://mochi.test:8888/browser/" +
|
|
|
|
"dom/tests/browser/browser_geolocation_privatebrowsing_page.html";
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
2013-02-05 23:38:01 -08:00
|
|
|
var windowsToClose = [];
|
2012-12-06 18:13:15 -08:00
|
|
|
function testOnWindow(aIsPrivate, aCallback) {
|
|
|
|
var win = OpenBrowserWindow({private: aIsPrivate});
|
2013-02-05 23:38:01 -08:00
|
|
|
win.addEventListener("load", function onLoad() {
|
|
|
|
win.removeEventListener("load", onLoad, false);
|
|
|
|
windowsToClose.push(win);
|
|
|
|
executeSoon(function() { aCallback(win); });
|
|
|
|
}, false);
|
2012-12-06 18:13:15 -08:00
|
|
|
}
|
|
|
|
|
2013-02-05 23:38:01 -08:00
|
|
|
registerCleanupFunction(function () {
|
|
|
|
windowsToClose.forEach(function(win) {
|
|
|
|
win.close();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2012-12-06 18:13:15 -08:00
|
|
|
testOnWindow(false, function(aNormalWindow) {
|
|
|
|
aNormalWindow.gBrowser.selectedBrowser.addEventListener("georesult", function load(ev) {
|
|
|
|
aNormalWindow.gBrowser.selectedBrowser.removeEventListener("georesult", load, false);
|
|
|
|
is(ev.detail, 200, "unexpected access token");
|
|
|
|
|
|
|
|
prefs.setCharPref("geo.wifi.uri", baseProvider + "?desired_access_token=ggg");
|
|
|
|
|
|
|
|
testOnWindow(true, function(aPrivateWindow) {
|
|
|
|
aPrivateWindow.gBrowser.selectedBrowser.addEventListener("georesult", function load2(ev) {
|
|
|
|
aPrivateWindow.gBrowser.selectedBrowser.removeEventListener("georesult", load2, false);
|
|
|
|
is(ev.detail, 200, "unexpected access token");
|
|
|
|
|
|
|
|
prefs.setCharPref("geo.wifi.uri", baseProvider + "?expected_access_token=fff");
|
|
|
|
|
2013-02-05 23:38:01 -08:00
|
|
|
testOnWindow(false, function(aAnotherNormalWindow) {
|
|
|
|
aAnotherNormalWindow.gBrowser.selectedBrowser.addEventListener("georesult", function load3(ev) {
|
|
|
|
aAnotherNormalWindow.gBrowser.selectedBrowser.removeEventListener("georesult", load3, false);
|
2012-12-06 18:13:15 -08:00
|
|
|
is(ev.detail, 200, "unexpected access token");
|
|
|
|
prefs.setBoolPref("geo.prompt.testing", false);
|
|
|
|
prefs.setBoolPref("geo.prompt.testing.allow", false);
|
2013-02-05 23:38:01 -08:00
|
|
|
|
2012-12-06 18:13:15 -08:00
|
|
|
finish();
|
|
|
|
}, false, true);
|
2013-02-05 23:38:01 -08:00
|
|
|
aAnotherNormalWindow.content.location = testPageURL;
|
2012-12-06 18:13:15 -08:00
|
|
|
});
|
|
|
|
}, false, true);
|
|
|
|
aPrivateWindow.content.location = testPageURL;
|
|
|
|
});
|
|
|
|
}, false, true);
|
|
|
|
aNormalWindow.content.location = testPageURL;
|
|
|
|
});
|
|
|
|
}
|