Bug 1081772 - Add back a way to test UITour on origins not whitelisted by default. r=Unfocused

This commit is contained in:
Matthew Noorenberghe 2014-10-16 00:12:09 -07:00
Родитель e1a9cfd648
Коммит 2fc18f4ce6
2 изменённых файлов: 41 добавлений и 1 удалений

Просмотреть файл

@ -26,6 +26,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "BrowserUITelemetry",
const UITOUR_PERMISSION = "uitour";
const PREF_TEST_WHITELIST = "browser.uitour.testingOrigins";
const PREF_SEENPAGEIDS = "browser.uitour.seenPageIDs";
const MAX_BUTTONS = 4;
@ -620,6 +621,25 @@ this.UITour = {
.wrappedJSObject;
},
isTestingOrigin: function(aURI) {
if (Services.prefs.getPrefType(PREF_TEST_WHITELIST) != Services.prefs.PREF_STRING) {
return false;
}
// Add any testing origins (comma-seperated) to the whitelist for the session.
for (let origin of Services.prefs.getCharPref(PREF_TEST_WHITELIST).split(",")) {
try {
let testingURI = Services.io.newURI(origin, null, null);
if (aURI.prePath == testingURI.prePath) {
return true;
}
} catch (ex) {
Cu.reportError(ex);
}
}
return false;
},
ensureTrustedOrigin: function(aDocument) {
if (aDocument.defaultView.top != aDocument.defaultView)
return false;
@ -633,7 +653,10 @@ this.UITour = {
return false;
let permission = Services.perms.testPermission(uri, UITOUR_PERMISSION);
return permission == Services.perms.ALLOW_ACTION;
if (permission == Services.perms.ALLOW_ACTION)
return true;
return this.isTestingOrigin(uri);
},
isSafeScheme: function(aURI) {

Просмотреть файл

@ -25,6 +25,23 @@ let tests = [
done();
}, "http://mochi.test:8888/");
},
function test_testing_host(done) {
// Add two testing origins intentionally surrounded by whitespace to be ignored.
Services.prefs.setCharPref("browser.uitour.testingOrigins",
"https://test1.example.com, https://test2.example.com:443 ");
registerCleanupFunction(() => {
Services.prefs.clearUserPref("browser.uitour.testingOrigins");
});
function callback(result) {
ok(result, "Callback should be called on a testing origin");
done();
}
loadUITourTestPage(function() {
gContentAPI.getConfiguration("appinfo", callback);
}, "https://test2.example.com/");
},
function test_unsecure_host(done) {
loadUITourTestPage(function() {
let bookmarksMenu = document.getElementById("bookmarks-menu-button");