Bug 1373650. Update webcompat-reporter tests. r=Gijs
authorMike Taylor <miket@mozilla.com>
Thu, 03 Aug 2017 23:19:23 -0500
changeset 374149 0f9b774eac91
parent 374148 a0b6db321f82
child 374150 4976f279c96f
push id48578
push usermitaylor@mozilla.com
push dateFri, 11 Aug 2017 18:29:20 +0000
treeherderautoland@449c8d0f859e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1373650
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1373650. Update webcompat-reporter tests. r=Gijs MozReview-Commit-ID: Bekl3MAjByC
browser/extensions/webcompat-reporter/test/browser/browser_button_state.js
browser/extensions/webcompat-reporter/test/browser/browser_report_site_issue.js
browser/extensions/webcompat-reporter/test/browser/head.js
--- a/browser/extensions/webcompat-reporter/test/browser/browser_button_state.js
+++ b/browser/extensions/webcompat-reporter/test/browser/browser_button_state.js
@@ -1,29 +1,23 @@
 const REPORTABLE_PAGE = "http://example.com/";
 const REPORTABLE_PAGE2 = "https://example.com/";
 const NONREPORTABLE_PAGE = "about:blank";
 
 /* Test that the Report Site Issue button is enabled for http and https tabs,
    on page load, or TabSelect, and disabled for everything else. */
 add_task(async function test_button_state_disabled() {
-  CustomizableUI.addWidgetToArea("webcompat-reporter-button", "nav-bar");
   let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, REPORTABLE_PAGE);
+  openPageActions();
   is(isButtonDisabled(), false, "Check that button is enabled for reportable schemes on tab load");
 
   let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, NONREPORTABLE_PAGE);
+  openPageActions();
   is(isButtonDisabled(), true, "Check that button is disabled for non-reportable schemes on tab load");
 
   let tab3 = await BrowserTestUtils.openNewForegroundTab(gBrowser, REPORTABLE_PAGE2);
+  openPageActions();
   is(isButtonDisabled(), false, "Check that button is enabled for reportable schemes on tab load");
 
-
-  await BrowserTestUtils.switchTab(gBrowser, tab2);
-  is(isButtonDisabled(), true, "Check that button is disabled for non-reportable schemes on TabSelect");
-
-  await BrowserTestUtils.switchTab(gBrowser, tab1);
-  is(isButtonDisabled(), false, "Check that button is enabled for reportable schemes on TabSelect");
-
-  CustomizableUI.reset();
   await BrowserTestUtils.removeTab(tab1);
   await BrowserTestUtils.removeTab(tab2);
   await BrowserTestUtils.removeTab(tab3);
 });
--- a/browser/extensions/webcompat-reporter/test/browser/browser_report_site_issue.js
+++ b/browser/extensions/webcompat-reporter/test/browser/browser_report_site_issue.js
@@ -1,23 +1,23 @@
 /* Test that clicking on the Report Site Issue button opens a new tab
    and sends a postMessaged blob to it. */
 add_task(async function test_screenshot() {
-  CustomizableUI.addWidgetToArea("webcompat-reporter-button", "nav-bar");
   requestLongerTimeout(2);
 
   // ./head.js sets the value for PREF_WC_REPORTER_ENDPOINT
   await SpecialPowers.pushPrefEnv({set: [[PREF_WC_REPORTER_ENDPOINT, NEW_ISSUE_PAGE]]});
 
   let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE);
 
-  let webcompatButton = document.getElementById("webcompat-reporter-button");
+  let webcompatButton = document.getElementById(WC_PAGE_ACTION_ID);
   ok(webcompatButton, "Report Site Issue button exists.");
 
   let newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser);
+  openPageActions();
   webcompatButton.click();
   let tab2 = await newTabPromise;
 
   await BrowserTestUtils.waitForContentEvent(tab2.linkedBrowser, "ScreenshotReceived", false, null, true);
 
   await ContentTask.spawn(tab2.linkedBrowser, {TEST_PAGE}, function(args) {
     let doc = content.document;
     let urlParam = doc.getElementById("url").innerText;
@@ -25,10 +25,9 @@ add_task(async function test_screenshot(
     is(urlParam, args.TEST_PAGE, "Reported page is correctly added to the url param");
 
     is(preview.innerText, "Pass", "A Blob object was successfully transferred to the test page.")
     ok(preview.style.backgroundImage.startsWith("url(\"data:image/png;base64,iVBOR"), "A green screenshot was successfully postMessaged");
   });
 
   await BrowserTestUtils.removeTab(tab2);
   await BrowserTestUtils.removeTab(tab1);
-  CustomizableUI.reset();
 });
--- a/browser/extensions/webcompat-reporter/test/browser/head.js
+++ b/browser/extensions/webcompat-reporter/test/browser/head.js
@@ -1,10 +1,17 @@
 const PREF_WC_REPORTER_ENABLED = "extensions.webcompat-reporter.enabled";
 const PREF_WC_REPORTER_ENDPOINT = "extensions.webcompat-reporter.newIssueEndpoint";
 
 const TEST_ROOT = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "http://example.com");
 const TEST_PAGE = TEST_ROOT + "test.html";
 const NEW_ISSUE_PAGE = TEST_ROOT + "webcompat.html";
 
+const WC_PAGE_ACTION_ID = "pageAction-panel-webcompat-reporter-button";
+
 function isButtonDisabled() {
-  return document.getElementById("webcompat-reporter-button").disabled;
+  return document.getElementById(WC_PAGE_ACTION_ID).disabled;
 }
+
+function openPageActions() {
+  var event = new MouseEvent("click");
+  BrowserPageActions.mainButtonClicked(event);
+}