Bug 1577031 - make Protection Report page sharable via UITour. r=johannh

Differential Revision: https://phabricator.services.mozilla.com/D44249

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Erica Wright 2019-09-06 15:45:28 +00:00
Родитель ea46baf631
Коммит da3ac3c2ca
4 изменённых файлов: 74 добавлений и 0 удалений

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

@ -371,6 +371,14 @@ if (typeof Mozilla == "undefined") {
_sendEvent("showNewTab");
};
/**
* Loads about:protections in the tour tab.
* @since 70
*/
Mozilla.UITour.showProtectionReport = function() {
_sendEvent("showProtectionReport");
};
/**
* @typedef Mozilla.UITour.ConfigurationName
* @description Valid values:<ul>

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

@ -709,6 +709,11 @@ var UITour = {
}
break;
}
case "showProtectionReport": {
this.showProtectionReport(window, browser);
break;
}
}
// For performance reasons, only call initForBrowser if we did something
@ -1554,6 +1559,17 @@ var UITour = {
});
},
showProtectionReport(aWindow, aBrowser) {
let url = "about:protections";
aWindow.openLinkIn(url, "current", {
targetBrowser: aBrowser,
triggeringPrincipal: Services.scriptSecurityManager.createContentPrincipal(
Services.io.newURI(url),
{}
),
});
},
_hideAnnotationsForPanel(aEvent, aShouldClosePanel, aTargetPositionCallback) {
let win = aEvent.target.ownerGlobal;
let hideHighlightMethod = null;

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

@ -38,6 +38,8 @@ skip-if = true # Disabled pending removal of pocket UI Tour
skip-if = (verify && !debug && (os == 'linux'))
[browser_UITour_showNewTab.js]
skip-if = (verify && !debug && (os == 'linux'))
[browser_UITour_showProtectionReport.js]
skip-if = (verify && !debug && (os == 'linux'))
[browser_UITour_sync.js]
[browser_UITour_toggleReaderMode.js]
skip-if = (verify && !debug && (os == 'linux'))

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

@ -0,0 +1,48 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var gTestTab;
var gContentAPI;
var gContentWindow;
add_task(setup_UITourTest);
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.contentblocking.database.enabled", false],
["browser.contentblocking.report.monitor.enabled", false],
["browser.contentblocking.report.lockwise.enabled", false],
["browser.contentblocking.report.proxy.enabled", false],
],
});
});
// Test that we can switch to about:protections
add_UITour_task(async function test_openProtectionReport() {
let aboutProtectionsLoaded = BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
false,
"about:protections"
);
info("Showing about:protections");
await gContentAPI.showProtectionReport();
info("Waiting for about:protections to load");
await aboutProtectionsLoaded;
// When the graph is built it means the messaging has finished,
// we can close the tab.
await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
await ContentTaskUtils.waitForCondition(() => {
let bars = content.document.querySelectorAll(".graph-bar");
return bars.length;
}, "The graph has been built");
});
is(
gBrowser.selectedBrowser.currentURI.spec,
"about:protections",
"Loaded about:protections"
);
});