Bug 1499096 - Update tests using ok() to is(), with minor fixes;r=Standard8
authorJulian Descottes <jdescottes@mozilla.com>
Tue, 23 Oct 2018 07:21:18 +0000
changeset 490877 2e4bdafb70ce4febc9fb071ad1743cc0b49096de
parent 490876 dfaaf3978e3c7f1c98fd20270a0e50e4a6ddd733
child 490878 d9c2a804cbc8188d5b15e3c8038ea27300ab79a6
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersStandard8
bugs1499096
milestone65.0a1
Bug 1499096 - Update tests using ok() to is(), with minor fixes;r=Standard8 Depends on D8741 This changeset updates some calls to ok() that should actually be calls to is() and that needed tiny fixes to match the expected value. Differential Revision: https://phabricator.services.mozilla.com/D8742
browser/base/content/test/tabs/browser_multiselect_tabs_using_selectedTabs.js
browser/components/preferences/in-content/tests/browser_homepages_use_bookmark.js
devtools/client/webide/test/test_autoconnect_runtime.html
devtools/client/webide/test/test_runtime.html
devtools/client/webide/test/test_toolbox.html
dom/broadcastchannel/tests/test_dataURL.html
--- a/browser/base/content/test/tabs/browser_multiselect_tabs_using_selectedTabs.js
+++ b/browser/base/content/test/tabs/browser_multiselect_tabs_using_selectedTabs.js
@@ -20,18 +20,19 @@ add_task(async function() {
     if (tabs.length == 1) {
       ok(!selectedTab.multiselected, "Selected tab shouldn't be multi-selected because we are not in multi-select context yet");
       ok(!_multiSelectedTabsSet.has(selectedTab), "Selected tab shouldn't be in _multiSelectedTabsSet");
       is(selectedTabs.length, 1, "selectedTabs should contain a single tab");
       is(selectedTabs[0], selectedTab, "selectedTabs should contain the selected tab");
       ok(!selectedTab.hasAttribute("aria-selected"),
          "Selected tab shouldn't be marked as aria-selected when only one tab is selected");
     } else {
-      ok(selectedTabs.length, tabs.length, "Check number of selected tabs");
-      for (let tab of tabs) {
+      const uniqueTabs = [...new Set(tabs)];
+      is(selectedTabs.length, uniqueTabs.length, "Check number of selected tabs");
+      for (let tab of uniqueTabs) {
         ok(tab.multiselected, "Tab should be multi-selected");
         ok(_multiSelectedTabsSet.has(tab), "Tab should be in _multiSelectedTabsSet");
         ok(selectedTabs.includes(tab), "Tab should be in selectedTabs");
         is(tab.getAttribute("aria-selected"), "true", "Selected tab should be marked as aria-selected");
       }
     }
   }
 
--- a/browser/components/preferences/in-content/tests/browser_homepages_use_bookmark.js
+++ b/browser/components/preferences/in-content/tests/browser_homepages_use_bookmark.js
@@ -1,22 +1,22 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
-const TEST_URL = "http://example.com";
+const TEST_URL = "http://example.com/";
 
 add_task(async function setup() {
   let oldHomepagePref = Services.prefs.getCharPref("browser.startup.homepage");
 
   await openPreferencesViaOpenPreferencesAPI("paneHome", {leaveOpen: true});
 
-  Assert.ok(gBrowser.currentURI.spec, "about:preferences#home",
-            "#home should be in the URI for about:preferences");
+  Assert.equal(gBrowser.currentURI.spec, "about:preferences#home",
+               "#home should be in the URI for about:preferences");
 
   registerCleanupFunction(async () => {
     Services.prefs.setCharPref("browser.startup.homepage", oldHomepagePref);
     BrowserTestUtils.removeTab(gBrowser.selectedTab);
     await PlacesUtils.bookmarks.eraseEverything();
   });
 });
 
@@ -37,11 +37,11 @@ add_task(async function testSetHomepageF
   doc.getElementById("useBookmarkBtn").click();
 
   let dialog = await promiseSubDialogLoaded;
 
   dialog.document.getElementById("bookmarks").selectItems([bm.guid]);
 
   dialog.document.documentElement.getButton("accept").click();
 
-  Assert.ok(Services.prefs.getCharPref("browser.startup.homepage"), TEST_URL,
-            "Should have set the homepage to the same as the bookmark.");
+  Assert.equal(Services.prefs.getCharPref("browser.startup.homepage"), TEST_URL,
+               "Should have set the homepage to the same as the bookmark.");
 });
--- a/devtools/client/webide/test/test_autoconnect_runtime.html
+++ b/devtools/client/webide/test/test_autoconnect_runtime.html
@@ -47,17 +47,18 @@
 
           const panelNode = docRuntime.querySelector("#runtime-panel");
           const items = panelNode.querySelectorAll(".runtime-panel-item-usb");
           is(items.length, 1, "Found one runtime button");
 
           let connectionsChanged = waitForConnectionChange("opened", 2);
           items[0].click();
 
-          ok(win.document.querySelector("window").className, "busy", "UI is busy");
+          ok(win.document.querySelector("window").classList.contains("busy"),
+            "UI is busy");
           await win.UI._busyPromise;
 
           await connectionsChanged;
           is(Object.keys(DebuggerServer._connections).length, 2, "Connected");
 
           connectionsChanged = waitForConnectionChange("closed", 2);
 
           await nextTick();
--- a/devtools/client/webide/test/test_runtime.html
+++ b/devtools/client/webide/test/test_runtime.html
@@ -94,17 +94,18 @@
 
           const panelNode = docRuntime.querySelector("#runtime-panel");
           const items = panelNode.querySelectorAll(".runtime-panel-item-usb");
           is(items.length, 3, "Found 3 runtime buttons");
 
           let connectionsChanged = waitForConnectionChange("opened", 2);
           items[0].click();
 
-          ok(win.document.querySelector("window").className, "busy", "UI is busy");
+          ok(win.document.querySelector("window").classList.contains("busy"),
+            "UI is busy");
           await win.UI._busyPromise;
 
           await connectionsChanged;
           is(Object.keys(DebuggerServer._connections).length, 2, "Connected");
 
           await waitForUpdate(win, "runtime-global-actors");
 
           // Play button always disabled now, webapps actor removed
@@ -159,30 +160,32 @@
           await win.UI.toolboxPromise;
 
           await win.Cmds.disconnectRuntime();
 
           Services.prefs.setIntPref("devtools.webide.busyTimeout", 100);
 
           // Click the infinite runtime
           items[1].click();
-          ok(win.document.querySelector("window").className, "busy", "UI is busy");
+          ok(win.document.querySelector("window").classList.contains("busy"),
+            "UI is busy");
 
           // Wait for error message since connection never completes
           await new Promise(resolve => {
             win.UI.reportError = errorName => {
               if (errorName === "error_operationTimeout") {
                 resolve();
               }
             };
           });
 
           // Click the prolonged runtime
           items[2].click();
-          ok(win.document.querySelector("window").className, "busy", "UI is busy");
+          ok(win.document.querySelector("window").classList.contains("busy"),
+            "UI is busy");
 
           // Check for unexpected error message since this is prolonged
           const noErrorDeferred = new Promise((resolve, reject) => {
             win.UI.reportError = errorName => {
               if (errorName === "error_operationTimeout") {
                 reject();
               }
             };
--- a/devtools/client/webide/test/test_toolbox.html
+++ b/devtools/client/webide/test/test_toolbox.html
@@ -43,17 +43,18 @@
           const deferred = new Promise(resolve => {
             win.AppManager.connection.once(
                  win.Connection.Events.CONNECTED,
                  resolve);
           });
 
           docRuntime.querySelectorAll(".runtime-panel-item-other")[1].click();
 
-          ok(win.document.querySelector("window").className, "busy", "UI is busy");
+          ok(win.document.querySelector("window").classList.contains("busy"),
+            "UI is busy");
           await win.UI._busyPromise;
 
           await deferred;
 
           is(Object.keys(DebuggerServer._connections).length, 1, "Connected");
 
           await waitForUpdate(win, "runtime-global-actors");
 
--- a/dom/broadcastchannel/tests/test_dataURL.html
+++ b/dom/broadcastchannel/tests/test_dataURL.html
@@ -13,17 +13,17 @@ a.onmessage = function(e) { parent.postM
 b.postMessage(42);
 </div>
 
 <script>
 
 SimpleTest.waitForExplicitFinish();
 
 onmessage= function(e) {
-  ok(e.data, "42", "BroadcastChannel works with data URLs");
+  is(e.data, 42, "BroadcastChannel works with data URLs");
   SimpleTest.finish();
 }
 
 var url = "data:text/html,<script>" + document.getElementById("dataURL").textContent + "</" + "script>";
 
 var ifr = document.createElement('iframe');
 document.body.appendChild(ifr);