Bug 1322726 - add UITour API to support opening about:newtab in the current tab, r=MattN a=lizzard
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 15 Dec 2016 14:30:36 +0000
changeset 353362 af31714b030937127b158c1c000cf975a0d4384d
parent 353361 16e1a0ce86e4e4b8066793ae9a89ba2ab19ecd69
child 353363 75a0d7ccab1c43dc878ef1082117a30161f52d91
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN, lizzard
bugs1322726
milestone52.0a2
Bug 1322726 - add UITour API to support opening about:newtab in the current tab, r=MattN a=lizzard When running the tests by dir, I noticed the tracking protection test requires extra files to work, but don't list those, so I fixed that. MozReview-Commit-ID: FUi8XQImvbI
browser/components/uitour/UITour-lib.js
browser/components/uitour/UITour.jsm
browser/components/uitour/test/browser.ini
browser/components/uitour/test/browser_UITour_showNewTab.js
--- a/browser/components/uitour/UITour-lib.js
+++ b/browser/components/uitour/UITour-lib.js
@@ -215,16 +215,20 @@ if (typeof Mozilla == 'undefined') {
   };
 
   Mozilla.UITour.hideMenu = function(name) {
     _sendEvent('hideMenu', {
       name: name
     });
   };
 
+  Mozilla.UITour.showNewTab = function() {
+    _sendEvent('showNewTab');
+  };
+
   Mozilla.UITour.getConfiguration = function(configName, callback) {
     _sendEvent('getConfiguration', {
       callbackID: _waitForCallback(callback),
       configuration: configName,
     });
   };
 
   Mozilla.UITour.setConfiguration = function(configName, configValue) {
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -522,16 +522,21 @@ this.UITour = {
         break;
       }
 
       case "hideMenu": {
         this.hideMenu(window, data.name);
         break;
       }
 
+      case "showNewTab": {
+        this.showNewTab(window, browser);
+        break;
+      }
+
       case "getConfiguration": {
         if (typeof data.configuration != "string") {
           log.warn("getConfiguration: No configuration option specified");
           return false;
         }
 
         this.getConfiguration(messageManager, window, data.configuration, data.callbackID);
         break;
@@ -1739,16 +1744,20 @@ this.UITour = {
       let menuBtn = aWindow.document.getElementById("bookmarks-menu-button");
       closeMenuButton(menuBtn);
     } else if (aMenuName == "controlCenter") {
       let panel = aWindow.gIdentityHandler._identityPopup;
       panel.hidePopup();
     }
   },
 
+  showNewTab: function(aWindow, aBrowser) {
+    aWindow.openLinkIn("about:newtab", "current", {targetBrowser: aBrowser});
+  },
+
   hideAnnotationsForPanel: function(aEvent, aTargetPositionCallback) {
     let win = aEvent.target.ownerGlobal;
     let annotationElements = new Map([
       // [annotationElement (panel), method to hide the annotation]
       [win.document.getElementById("UITourHighlightContainer"), UITour.hideHighlight.bind(UITour)],
       [win.document.getElementById("UITourTooltip"), UITour.hideInfo.bind(UITour)],
     ]);
     annotationElements.forEach((hideMethod, annotationElement) => {
--- a/browser/components/uitour/test/browser.ini
+++ b/browser/components/uitour/test/browser.ini
@@ -11,16 +11,19 @@ support-files =
 skip-if = debug || asan # updateAppMenuItem leaks
 [browser_no_tabs.js]
 [browser_openPreferences.js]
 [browser_openSearchPanel.js]
 skip-if = true # Bug 1113038 - Intermittent "Popup was opened"
 [browser_trackingProtection.js]
 skip-if = os == "linux" # Intermittent NS_ERROR_NOT_AVAILABLE [nsIUrlClassifierDBService.beginUpdate]
 tag = trackingprotection
+support-files =
+  !/browser/base/content/test/general/benignPage.html
+  !/browser/base/content/test/general/trackingPage.html
 [browser_trackingProtection_tour.js]
 tag = trackingprotection
 [browser_showMenu_controlCenter.js]
 tag = trackingprotection
 [browser_UITour.js]
 skip-if = os == "linux" # Intermittent failures, bug 951965
 [browser_UITour2.js]
 [browser_UITour3.js]
@@ -36,10 +39,11 @@ skip-if = os == "win" # Bug 1277107
 skip-if = os != "mac" # modal dialog disabling only working on OS X.
 [browser_UITour_observe.js]
 [browser_UITour_panel_close_annotation.js]
 skip-if = true # Disabled due to frequent failures, bugs 1026310 and 1032137
 [browser_UITour_pocket.js]
 skip-if = true # Disabled pending removal of pocket UI Tour
 [browser_UITour_registerPageID.js]
 [browser_UITour_resetProfile.js]
+[browser_UITour_showNewTab.js]
 [browser_UITour_sync.js]
 [browser_UITour_toggleReaderMode.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/uitour/test/browser_UITour_showNewTab.js
@@ -0,0 +1,17 @@
+"use strict";
+
+var gTestTab;
+var gContentAPI;
+var gContentWindow;
+
+add_task(setup_UITourTest);
+
+// Test that we can switch to about:newtab
+add_UITour_task(function* test_aboutNewTab() {
+  let newTabLoaded = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, "about:newtab");
+  info("Showing about:newtab");
+  yield gContentAPI.showNewTab();
+  info("Waiting for about:newtab to load");
+  yield newTabLoaded;
+  is(gBrowser.selectedBrowser.currentURI.spec, "about:newtab", "Loaded about:newtab");
+});