Bug 1288885: Migrate history mochitests to xpcshell. r=aswan
☠☠ backed out by 0391561d533b ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Fri, 22 Jul 2016 18:57:38 -0700
changeset 349097 eeb6bc8a42e69e989bb70cc6daf56296936f60b0
parent 349096 fca55647234643b6fde3b62b3337e491432ab0dc
child 349098 43cf27f0e2edb5136c1fa3fe415841f52ee62ec9
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1288885
milestone50.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 1288885: Migrate history mochitests to xpcshell. r=aswan MozReview-Commit-ID: tzQdEJx6TN
browser/components/extensions/test/browser/browser.ini
browser/components/extensions/test/browser/browser_ext_history.js
browser/components/extensions/test/xpcshell/test_ext_history.js
browser/components/extensions/test/xpcshell/xpcshell.ini
--- a/browser/components/extensions/test/browser/browser.ini
+++ b/browser/components/extensions/test/browser/browser.ini
@@ -30,17 +30,16 @@ support-files =
 [browser_ext_contextMenus.js]
 [browser_ext_contextMenus_checkboxes.js]
 [browser_ext_contextMenus_icons.js]
 [browser_ext_contextMenus_radioGroups.js]
 [browser_ext_contextMenus_uninstall.js]
 [browser_ext_contextMenus_urlPatterns.js]
 [browser_ext_currentWindow.js]
 [browser_ext_getViews.js]
-[browser_ext_history.js]
 [browser_ext_incognito_popup.js]
 [browser_ext_lastError.js]
 [browser_ext_optionsPage_privileges.js]
 [browser_ext_pageAction_context.js]
 [browser_ext_pageAction_popup.js]
 [browser_ext_pageAction_popup_resize.js]
 [browser_ext_pageAction_simple.js]
 [browser_ext_popup_api_injection.js]
rename from browser/components/extensions/test/browser/browser_ext_history.js
rename to browser/components/extensions/test/xpcshell/test_ext_history.js
--- a/browser/components/extensions/test/browser/browser_ext_history.js
+++ b/browser/components/extensions/test/xpcshell/test_ext_history.js
@@ -80,58 +80,58 @@ add_task(function* test_delete() {
       }
     } else {
       pushVisit(visit.visits);
     }
     visits.push(visit);
   }
 
   yield PlacesUtils.history.insertMany(visits);
-  is(yield PlacesTestUtils.visitsInDB(visits[0].url), 5, "5 visits for uri found in history database");
+  equal((yield PlacesTestUtils.visitsInDB(visits[0].url)), 5, "5 visits for uri found in history database");
 
   let testUrl = visits[2].url;
-  ok(yield PlacesTestUtils.isPageInDB(testUrl), "expected url found in history database");
+  ok((yield PlacesTestUtils.isPageInDB(testUrl)), "expected url found in history database");
 
   extension.sendMessage("delete-url", testUrl);
   yield extension.awaitMessage("url-deleted");
-  is(yield PlacesTestUtils.isPageInDB(testUrl), false, "expected url not found in history database");
+  equal((yield PlacesTestUtils.isPageInDB(testUrl)), false, "expected url not found in history database");
 
   // delete 3 of the 5 visits for url 1
   let filter = {
     startTime: visits[0].visits[0].date,
     endTime: visits[0].visits[2].date,
   };
 
   extension.sendMessage("delete-range", filter);
   let removedUrls = yield extension.awaitMessage("range-deleted");
   ok(!removedUrls.includes(visits[0].url), `${visits[0].url} not received by onVisitRemoved`);
-  ok(yield PlacesTestUtils.isPageInDB(visits[0].url), "expected uri found in history database");
-  is(yield PlacesTestUtils.visitsInDB(visits[0].url), 2, "2 visits for uri found in history database");
-  ok(yield PlacesTestUtils.isPageInDB(visits[1].url), "expected uri found in history database");
-  is(yield PlacesTestUtils.visitsInDB(visits[1].url), 1, "1 visit for uri found in history database");
+  ok((yield PlacesTestUtils.isPageInDB(visits[0].url)), "expected uri found in history database");
+  equal((yield PlacesTestUtils.visitsInDB(visits[0].url)), 2, "2 visits for uri found in history database");
+  ok((yield PlacesTestUtils.isPageInDB(visits[1].url)), "expected uri found in history database");
+  equal((yield PlacesTestUtils.visitsInDB(visits[1].url)), 1, "1 visit for uri found in history database");
 
   // delete the rest of the visits for url 1, and the visit for url 2
   filter.startTime = visits[0].visits[0].date;
   filter.endTime = visits[1].visits[0].date;
 
   extension.sendMessage("delete-range", filter);
   yield extension.awaitMessage("range-deleted");
 
-  is(yield PlacesTestUtils.isPageInDB(visits[0].url), false, "expected uri not found in history database");
-  is(yield PlacesTestUtils.visitsInDB(visits[0].url), 0, "0 visits for uri found in history database");
-  is(yield PlacesTestUtils.isPageInDB(visits[1].url), false, "expected uri not found in history database");
-  is(yield PlacesTestUtils.visitsInDB(visits[1].url), 0, "0 visits for uri found in history database");
+  equal((yield PlacesTestUtils.isPageInDB(visits[0].url)), false, "expected uri not found in history database");
+  equal((yield PlacesTestUtils.visitsInDB(visits[0].url)), 0, "0 visits for uri found in history database");
+  equal((yield PlacesTestUtils.isPageInDB(visits[1].url)), false, "expected uri not found in history database");
+  equal((yield PlacesTestUtils.visitsInDB(visits[1].url)), 0, "0 visits for uri found in history database");
 
-  ok(yield PlacesTestUtils.isPageInDB(visits[3].url), "expected uri found in history database");
+  ok((yield PlacesTestUtils.isPageInDB(visits[3].url)), "expected uri found in history database");
 
   extension.sendMessage("delete-all");
   [historyClearedCount, removedUrls] = yield extension.awaitMessage("history-cleared");
-  is(PlacesUtils.history.hasHistoryEntries, false, "history is empty");
-  is(historyClearedCount, 2, "onVisitRemoved called for each clearing of history");
-  is(removedUrls.length, 3, "onVisitRemoved called the expected number of times");
+  equal(PlacesUtils.history.hasHistoryEntries, false, "history is empty");
+  equal(historyClearedCount, 2, "onVisitRemoved called for each clearing of history");
+  equal(removedUrls.length, 3, "onVisitRemoved called the expected number of times");
   for (let i = 1; i < 3; ++i) {
     let url = visits[i].url;
     ok(removedUrls.includes(url), `${url} received by onVisitRemoved`);
   }
   yield extension.unload();
 });
 
 add_task(function* test_search() {
@@ -210,45 +210,45 @@ add_task(function* test_search() {
   });
 
   function findResult(url, results) {
     return results.find(r => r.url === url);
   }
 
   function checkResult(results, url, expectedCount) {
     let result = findResult(url, results);
-    isnot(result, null, `history.search result was found for ${url}`);
-    is(result.visitCount, expectedCount, `history.search reports ${expectedCount} visit(s)`);
-    is(result.title, `test visit for ${url}`, "title for search result is correct");
+    notEqual(result, null, `history.search result was found for ${url}`);
+    equal(result.visitCount, expectedCount, `history.search reports ${expectedCount} visit(s)`);
+    equal(result.title, `test visit for ${url}`, "title for search result is correct");
   }
 
   yield extension.startup();
   yield extension.awaitMessage("ready");
   yield PlacesTestUtils.clearHistory();
 
   yield PlacesUtils.history.insertMany(PAGE_INFOS);
 
   extension.sendMessage("check-history");
 
   let results = yield extension.awaitMessage("empty-search");
-  is(results.length, 3, "history.search with empty text returned 3 results");
+  equal(results.length, 3, "history.search with empty text returned 3 results");
   checkResult(results, SINGLE_VISIT_URL, 1);
   checkResult(results, DOUBLE_VISIT_URL, 2);
   checkResult(results, MOZILLA_VISIT_URL, 1);
 
   results = yield extension.awaitMessage("text-search");
-  is(results.length, 1, "history.search with specific text returned 1 result");
+  equal(results.length, 1, "history.search with specific text returned 1 result");
   checkResult(results, MOZILLA_VISIT_URL, 1);
 
   results = yield extension.awaitMessage("max-results-search");
-  is(results.length, 1, "history.search with maxResults returned 1 result");
+  equal(results.length, 1, "history.search with maxResults returned 1 result");
   checkResult(results, DOUBLE_VISIT_URL, 2);
 
   results = yield extension.awaitMessage("date-range-search");
-  is(results.length, 2, "history.search with a date range returned 2 result");
+  equal(results.length, 2, "history.search with a date range returned 2 result");
   checkResult(results, DOUBLE_VISIT_URL, 2);
   checkResult(results, SINGLE_VISIT_URL, 1);
 
   yield extension.awaitFinish("search");
   yield extension.unload();
   yield PlacesTestUtils.clearHistory();
 });
 
@@ -295,21 +295,21 @@ add_task(function* test_add_url() {
 
   let failTestData = [
     [{transition: "generated"}, "an invalid transition", "|generated| is not a supported transition for history"],
     [{visitTime: Date.now() + 1000000}, "a future date", "cannot be a future date"],
     [{url: "about.config"}, "an invalid url", "about.config is not a valid URL"],
   ];
 
   function* checkUrl(results) {
-    ok(yield PlacesTestUtils.isPageInDB(results.details.url), `${results.details.url} found in history database`);
+    ok((yield PlacesTestUtils.isPageInDB(results.details.url)), `${results.details.url} found in history database`);
     ok(PlacesUtils.isValidGuid(results.result.id), "URL was added with a valid id");
-    is(results.result.title, results.details.title, "URL was added with the correct title");
+    equal(results.result.title, results.details.title, "URL was added with the correct title");
     if (results.details.visitTime) {
-      is(results.result.lastVisitTime,
+      equal(results.result.lastVisitTime,
          Number(ExtensionUtils.normalizeTime(results.details.visitTime)),
          "URL was added with the correct date");
     }
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: ["history"],
@@ -453,22 +453,22 @@ add_task(function* test_on_visited() {
 
   yield PlacesUtils.history.insertMany(PAGE_INFOS);
 
   let onVisitedData = yield extension.awaitMessage("on-visited-data");
 
   function checkOnVisitedData(index, expected) {
     let onVisited = onVisitedData[index];
     ok(PlacesUtils.isValidGuid(onVisited.id), "onVisited received a valid id");
-    is(onVisited.url, expected.url, "onVisited received the expected url");
+    equal(onVisited.url, expected.url, "onVisited received the expected url");
     // Title will be blank until bug 1287928 lands
     // https://bugzilla.mozilla.org/show_bug.cgi?id=1287928
-    is(onVisited.title, "", "onVisited received a blank title");
-    is(onVisited.lastVisitTime, expected.time, "onVisited received the expected time");
-    is(onVisited.visitCount, expected.visitCount, "onVisited received the expected visitCount");
+    equal(onVisited.title, "", "onVisited received a blank title");
+    equal(onVisited.lastVisitTime, expected.time, "onVisited received the expected time");
+    equal(onVisited.visitCount, expected.visitCount, "onVisited received the expected visitCount");
   }
 
   let expected = {
     url: PAGE_INFOS[0].url,
     title: PAGE_INFOS[0].title,
     time: PAGE_INFOS[0].visits[0].date.getTime(),
     visitCount: 1,
   };
--- a/browser/components/extensions/test/xpcshell/xpcshell.ini
+++ b/browser/components/extensions/test/xpcshell/xpcshell.ini
@@ -1,7 +1,8 @@
 [DEFAULT]
 head = head.js
 tail =
 firefox-appdir = browser
 
 [test_ext_bookmarks.js]
+[test_ext_history.js]
 [test_ext_manifest_commands.js]