Skip to content

Commit 801590e

Browse files
author
Sandor Molnar
committed
Backed out changeset c8f7d19d58bb (bug 1789727) for causing telemetry/marionette/tests/client/test_subsession_management.py CLOSED TREE
1 parent 16e1274 commit 801590e

File tree

6 files changed

+53
-104
lines changed

6 files changed

+53
-104
lines changed

browser/app/profile/firefox.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,12 +2409,8 @@ pref("browser.suppress_first_window_animation", true);
24092409
// Preference that allows individual users to disable Screenshots.
24102410
pref("extensions.screenshots.disabled", false);
24112411

2412-
// Preference that determines whether Screenshots uses the dedicated browser component
2413-
#ifdef NIGHTLY_BUILD
2414-
pref("screenshots.browser.component.enabled", true);
2415-
#else
2416-
pref("screenshots.browser.component.enabled", false);
2417-
#endif
2412+
// Preference that determines whether Screenshots is opened as a dedicated browser component
2413+
pref("screenshots.browser.component.enabled", false);
24182414

24192415
// Preference that determines what button to focus
24202416
pref("screenshots.browser.component.last-saved-method", "download");

browser/base/content/test/performance/browser_startup_content_mainthreadio.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,6 @@ const processes = {
152152
condition: WIN,
153153
stat: 1,
154154
},
155-
{
156-
// We should remove this in bug 1882427
157-
path: "*screenshots@mozilla.org.xpi",
158-
condition: true,
159-
ignoreIfUnused: true,
160-
close: 1,
161-
},
162155
],
163156
};
164157

browser/components/BrowserGlue.sys.mjs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,31 +2142,26 @@ BrowserGlue.prototype = {
21422142
const COMPONENT_PREF = "screenshots.browser.component.enabled";
21432143
const ID = "screenshots@mozilla.org";
21442144
const _checkScreenshotsPref = async () => {
2145+
let addon = await lazy.AddonManager.getAddonByID(ID);
2146+
if (!addon) {
2147+
return;
2148+
}
21452149
let screenshotsDisabled = Services.prefs.getBoolPref(
21462150
SCREENSHOTS_PREF,
21472151
false
21482152
);
2149-
let componentEnabled = Services.prefs.getBoolPref(COMPONENT_PREF, true);
2150-
2151-
let screenshotsAddon = await lazy.AddonManager.getAddonByID(ID);
2152-
2153+
let componentEnabled = Services.prefs.getBoolPref(COMPONENT_PREF, false);
21532154
if (screenshotsDisabled) {
21542155
if (componentEnabled) {
21552156
lazy.ScreenshotsUtils.uninitialize();
2156-
} else if (screenshotsAddon?.isActive) {
2157-
await screenshotsAddon.disable({ allowSystemAddons: true });
2157+
} else {
2158+
await addon.disable({ allowSystemAddons: true });
21582159
}
21592160
} else if (componentEnabled) {
21602161
lazy.ScreenshotsUtils.initialize();
2161-
if (screenshotsAddon?.isActive) {
2162-
await screenshotsAddon.disable({ allowSystemAddons: true });
2163-
}
2162+
await addon.disable({ allowSystemAddons: true });
21642163
} else {
2165-
try {
2166-
await screenshotsAddon.enable({ allowSystemAddons: true });
2167-
} catch (ex) {
2168-
console.error(`Error trying to enable screenshots extension: ${ex}`);
2169-
}
2164+
await addon.enable({ allowSystemAddons: true });
21702165
lazy.ScreenshotsUtils.uninitialize();
21712166
}
21722167
};
@@ -2437,6 +2432,7 @@ BrowserGlue.prototype = {
24372432
LATE_TASKS_IDLE_TIME_SEC
24382433
);
24392434

2435+
this._monitorScreenshotsPref();
24402436
this._monitorWebcompatReporterPref();
24412437
this._monitorHTTPSOnlyPref();
24422438
this._monitorIonPref();
@@ -2909,9 +2905,13 @@ BrowserGlue.prototype = {
29092905
},
29102906

29112907
{
2912-
name: "BrowserGlue._monitorScreenshotsPref",
2908+
name: "ScreenshotsUtils.initialize",
29132909
task: () => {
2914-
this._monitorScreenshotsPref();
2910+
if (
2911+
Services.prefs.getBoolPref("screenshots.browser.component.enabled")
2912+
) {
2913+
lazy.ScreenshotsUtils.initialize();
2914+
}
29152915
},
29162916
},
29172917

browser/components/screenshots/ScreenshotsUtils.sys.mjs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,12 +544,7 @@ export var ScreenshotsUtils = {
544544
* @param browser The current browser.
545545
*/
546546
closeOverlay(browser, options = {}) {
547-
// If the actor has been unregistered (e.g. if the component enabled pref is flipped false)
548-
// its possible getActor will throw an exception. That's ok.
549-
let actor;
550-
try {
551-
actor = this.getActor(browser);
552-
} catch (ex) {}
547+
let actor = this.getActor(browser);
553548
actor?.sendAsyncMessage("Screenshots:HideOverlay", options);
554549

555550
if (this.browserToScreenshotsState.has(browser)) {

browser/components/screenshots/tests/browser/browser_screenshots_test_toggle_pref.js

Lines changed: 33 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const { sinon } = ChromeUtils.importESModule(
99

1010
ChromeUtils.defineESModuleGetters(this, {
1111
ScreenshotsUtils: "resource:///modules/ScreenshotsUtils.sys.mjs",
12-
AddonManager: "resource://gre/modules/AddonManager.sys.mjs",
1312
});
1413
ChromeUtils.defineLazyGetter(this, "ExtensionManagement", () => {
1514
const { Management } = ChromeUtils.importESModule(
@@ -18,11 +17,7 @@ ChromeUtils.defineLazyGetter(this, "ExtensionManagement", () => {
1817
return Management;
1918
});
2019

21-
const COMPONENT_PREF = "screenshots.browser.component.enabled";
22-
const SCREENSHOTS_PREF = "extensions.screenshots.disabled";
23-
const SCREENSHOT_EXTENSION = "screenshots@mozilla.org";
24-
25-
add_task(async function test_toggling_screenshots_pref() {
20+
add_task(async function test() {
2621
let observerSpy = sinon.spy();
2722
let notifierSpy = sinon.spy();
2823

@@ -36,24 +31,13 @@ add_task(async function test_toggling_screenshots_pref() {
3631
ScreenshotsUtils.notify.wrappedMethod.apply(this, arguments);
3732
});
3833

39-
// wait for startup idle tasks to complete
40-
await new Promise(resolve => ChromeUtils.idleDispatch(resolve));
41-
ok(Services.prefs.getBoolPref(COMPONENT_PREF), "Component enabled");
42-
ok(!Services.prefs.getBoolPref(SCREENSHOTS_PREF), "Screenshots enabled");
43-
44-
let addon = await AddonManager.getAddonByID(SCREENSHOT_EXTENSION);
45-
await BrowserTestUtils.waitForCondition(
46-
() => !addon.isActive,
47-
"The extension is not active when the component is prefd on"
48-
);
49-
5034
await BrowserTestUtils.withNewTab(
5135
{
5236
gBrowser,
5337
url: SHORT_TEST_PAGE,
5438
},
5539
async browser => {
56-
function extensionEventPromise(eventName, id) {
40+
function awaitExtensionEvent(eventName, id) {
5741
return new Promise(resolve => {
5842
let listener = (_eventName, ...args) => {
5943
let extension = args[0];
@@ -65,21 +49,9 @@ add_task(async function test_toggling_screenshots_pref() {
6549
ExtensionManagement.on(eventName, listener);
6650
});
6751
}
52+
const SCREENSHOT_EXTENSION = "screenshots@mozilla.org";
6853

6954
let helper = new ScreenshotsHelper(browser);
70-
ok(
71-
addon.userDisabled,
72-
"The extension is disabled when the component is prefd on"
73-
);
74-
ok(
75-
!addon.isActive,
76-
"The extension is not initially active when the component is prefd on"
77-
);
78-
await BrowserTestUtils.waitForCondition(
79-
() => ScreenshotsUtils.initialized,
80-
"The component is initialized"
81-
);
82-
ok(ScreenshotsUtils.initialized, "The component is initialized");
8355

8456
ok(observerSpy.notCalled, "Observer not called");
8557
helper.triggerUIFromToolbar();
@@ -108,20 +80,12 @@ add_task(async function test_toggling_screenshots_pref() {
10880

10981
Assert.equal(observerSpy.callCount, 3, "Observer function called thrice");
11082

111-
let extensionReadyPromise = extensionEventPromise(
112-
"ready",
113-
SCREENSHOT_EXTENSION
114-
);
115-
Services.prefs.setBoolPref(COMPONENT_PREF, false);
83+
const COMPONENT_PREF = "screenshots.browser.component.enabled";
84+
await SpecialPowers.pushPrefEnv({
85+
set: [[COMPONENT_PREF, false]],
86+
});
11687
ok(!Services.prefs.getBoolPref(COMPONENT_PREF), "Extension enabled");
117-
118-
info("Waiting for the extension ready event");
119-
await extensionReadyPromise;
120-
await BrowserTestUtils.waitForCondition(
121-
() => !addon.userDisabled,
122-
"The extension gets un-disabled when the component is prefd off"
123-
);
124-
ok(addon.isActive, "Extension is active");
88+
await awaitExtensionEvent("ready", SCREENSHOT_EXTENSION);
12589

12690
helper.triggerUIFromToolbar();
12791
Assert.equal(
@@ -130,7 +94,6 @@ add_task(async function test_toggling_screenshots_pref() {
13094
"Observer function still called thrice"
13195
);
13296

133-
info("Waiting for the extensions overlay");
13497
await SpecialPowers.spawn(
13598
browser,
13699
["#firefox-screenshots-preselection-iframe"],
@@ -152,7 +115,6 @@ add_task(async function test_toggling_screenshots_pref() {
152115
}
153116
);
154117

155-
info("Waiting for the extensions overlay");
156118
helper.triggerUIFromToolbar();
157119
await SpecialPowers.spawn(
158120
browser,
@@ -240,7 +202,9 @@ add_task(async function test_toggling_screenshots_pref() {
240202
"screenshots-component-initialized"
241203
);
242204

243-
Services.prefs.setBoolPref(COMPONENT_PREF, true);
205+
await SpecialPowers.pushPrefEnv({
206+
set: [[COMPONENT_PREF, true]],
207+
});
244208
ok(Services.prefs.getBoolPref(COMPONENT_PREF), "Component enabled");
245209
// Needed for component to initialize
246210
await componentReady;
@@ -251,6 +215,12 @@ add_task(async function test_toggling_screenshots_pref() {
251215
4,
252216
"Observer function called four times"
253217
);
218+
219+
const SCREENSHOTS_PREF = "extensions.screenshots.disabled";
220+
await SpecialPowers.pushPrefEnv({
221+
set: [[SCREENSHOTS_PREF, true]],
222+
});
223+
ok(Services.prefs.getBoolPref(SCREENSHOTS_PREF), "Screenshots disabled");
254224
}
255225
);
256226

@@ -260,9 +230,7 @@ add_task(async function test_toggling_screenshots_pref() {
260230
url: SHORT_TEST_PAGE,
261231
},
262232
async browser => {
263-
Services.prefs.setBoolPref(SCREENSHOTS_PREF, true);
264-
Services.prefs.setBoolPref(COMPONENT_PREF, true);
265-
233+
const SCREENSHOTS_PREF = "extensions.screenshots.disabled";
266234
ok(Services.prefs.getBoolPref(SCREENSHOTS_PREF), "Screenshots disabled");
267235

268236
ok(
@@ -287,22 +255,21 @@ add_task(async function test_toggling_screenshots_pref() {
287255
menu.hidePopup();
288256
await popuphidden;
289257

290-
let componentReady = TestUtils.topicObserved(
291-
"screenshots-component-initialized"
292-
);
293-
294-
Services.prefs.setBoolPref(SCREENSHOTS_PREF, false);
295-
258+
await SpecialPowers.pushPrefEnv({
259+
set: [[SCREENSHOTS_PREF, false]],
260+
});
296261
ok(!Services.prefs.getBoolPref(SCREENSHOTS_PREF), "Screenshots enabled");
262+
}
263+
);
297264

298-
await componentReady;
299-
300-
ok(ScreenshotsUtils.initialized, "The component is initialized");
301-
302-
ok(
303-
!document.getElementById("screenshot-button").disabled,
304-
"Toolbar button is enabled"
305-
);
265+
await BrowserTestUtils.withNewTab(
266+
{
267+
gBrowser,
268+
url: SHORT_TEST_PAGE,
269+
},
270+
async browser => {
271+
const SCREENSHOTS_PREF = "extensions.screenshots.disabled";
272+
ok(!Services.prefs.getBoolPref(SCREENSHOTS_PREF), "Screenshots enabled");
306273

307274
let helper = new ScreenshotsHelper(browser);
308275

@@ -317,4 +284,6 @@ add_task(async function test_toggling_screenshots_pref() {
317284

318285
observerStub.restore();
319286
notifierStub.restore();
287+
288+
await SpecialPowers.popPrefEnv();
320289
});

browser/extensions/screenshots/test/browser/browser.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
[DEFAULT]
2-
# The Screenshots extension is disabled by default in Mochitests. We re-enable it here, since it's a more realistic configuration.
3-
prefs = [
4-
"extensions.screenshots.disabled=false",
5-
"screenshots.browser.component.enabled=false",
6-
]
2+
prefs = ["extensions.screenshots.disabled=false",] # The Screenshots extension is disabled by default in Mochitests. We re-enable it here, since it's a more realistic configuration.
73

84
["browser_screenshot_button.js"]
95

0 commit comments

Comments
 (0)