Bug 1322726 - add UITour API to support opening about:newtab in the current tab, r?MattN draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 15 Dec 2016 14:30:36 +0000
changeset 449951 6027d111fa76c0e5a40749c804940dc73a0602b0
parent 449949 c750a7de1194d71f2d2ef73f6a919d26b9640cae
child 539626 81a88757097d9423e31a90eb58d3a67eb8b26e36
push id38717
push userbmo:gijskruitbosch+bugs@gmail.com
push dateThu, 15 Dec 2016 14:32:52 +0000
reviewersMattN
bugs1322726
milestone53.0a1
Bug 1322726 - add UITour API to support opening about:newtab in the current tab, r?MattN 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");
+});