зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1081772 - Add back a way to test UITour on origins not whitelisted by default. r=Unfocused
This commit is contained in:
Родитель
e1a9cfd648
Коммит
2fc18f4ce6
|
@ -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");
|
||||
|
|
Загрузка…
Ссылка в новой задаче