Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix and simplify Screenshots UI check test
Browse files Browse the repository at this point in the history
There's no need to flip the pref and poll for the page action to appear
or disappear. Instead, just directly enable or disable via the
AddonManager. This won't conflict with the pref observing code, because
that code only reacts to pref changes, not to addon state changes.
  • Loading branch information
jaredhirsch committed Oct 19, 2018
1 parent 8c4d4f2 commit d9a6cff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 66 deletions.
4 changes: 0 additions & 4 deletions test/addon/browser.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
[DEFAULT]
support-files =
head.js

[browser_screenshots_ui_check.js]
skip-if = os == 'win' && debug # Bug 1394967
17 changes: 12 additions & 5 deletions test/addon/browser_screenshots_ui_check.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"use strict";

ChromeUtils.defineModuleGetter(this, "AddonManager",
"resource://gre/modules/AddonManager.jsm");

const BUTTON_ID = "pageAction-panel-screenshots_mozilla_org";

function checkElements(expectPresent, l) {
Expand Down Expand Up @@ -68,11 +71,15 @@ function promisePageActionViewChildrenVisible(panelViewNode) {
}

add_task(async function() {
await promiseScreenshotsEnabled();

registerCleanupFunction(async function() {
await promiseScreenshotsReset();
});
// If Screenshots was disabled, enable it just for this test.
const addon = await AddonManager.getAddonByID("screenshots@mozilla.org");
const isEnabled = addon.enabled;
if (!isEnabled) {
await addon.enable({allowSystemAddons: true});
registerCleanupFunction(async () => {
await addon.disable({allowSystemAddons: true});
});
}

// Toggle the page action panel to get it to rebuild itself. An actionable
// page must be opened first.
Expand Down
57 changes: 0 additions & 57 deletions test/addon/head.js

This file was deleted.

0 comments on commit d9a6cff

Please sign in to comment.