Bug 1458230 - Stop passing the caller or a stack for Assert.ok messages in places tests. r=Paolo
authorMark Banner <standard8@mozilla.com>
Tue, 01 May 2018 15:27:37 +0100
changeset 472546 969b429c982e793de88d04011f4a1aa610ff8d6d
parent 472545 424ed2c8b1b4a7ef471552f1567b25d48da67275
child 472547 eb78f49f99f095346715906321a5730bf647dfec
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersPaolo
bugs1458230
milestone61.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 1458230 - Stop passing the caller or a stack for Assert.ok messages in places tests. r=Paolo The stacks are now correctly output by the test harness, they may not have been before. MozReview-Commit-ID: FugywVd9xoC
toolkit/components/places/tests/head_common.js
toolkit/components/places/tests/history/test_async_history_api.js
--- a/toolkit/components/places/tests/head_common.js
+++ b/toolkit/components/places/tests/head_common.js
@@ -599,111 +599,97 @@ function waitForConnectionClosed(aCallba
 /**
  * Tests if a given guid is valid for use in Places or not.
  *
  * @param aGuid
  *        The guid to test.
  * @param [optional] aStack
  *        The stack frame used to report the error.
  */
-function do_check_valid_places_guid(aGuid,
-                                    aStack) {
-  if (!aStack) {
-    aStack = Components.stack.caller;
-  }
-  Assert.ok(/^[a-zA-Z0-9\-_]{12}$/.test(aGuid), aStack);
+function do_check_valid_places_guid(aGuid) {
+  Assert.ok(/^[a-zA-Z0-9\-_]{12}$/.test(aGuid), "Should be a valid GUID");
 }
 
 /**
  * Retrieves the guid for a given uri.
  *
  * @param aURI
  *        The uri to check.
  * @param [optional] aStack
  *        The stack frame used to report the error.
  * @return the associated the guid.
  */
-function do_get_guid_for_uri(aURI,
-                             aStack) {
-  if (!aStack) {
-    aStack = Components.stack.caller;
-  }
+function do_get_guid_for_uri(aURI) {
   let stmt = DBConn().createStatement(
     `SELECT guid
      FROM moz_places
      WHERE url_hash = hash(:url) AND url = :url`
   );
   stmt.params.url = aURI.spec;
-  Assert.ok(stmt.executeStep(), aStack);
+  Assert.ok(stmt.executeStep(), "GUID for URI statement should succeed");
   let guid = stmt.row.guid;
   stmt.finalize();
-  do_check_valid_places_guid(guid, aStack);
+  do_check_valid_places_guid(guid);
   return guid;
 }
 
 /**
  * Tests that a guid was set in moz_places for a given uri.
  *
  * @param aURI
  *        The uri to check.
  * @param [optional] aGUID
  *        The expected guid in the database.
  */
 function do_check_guid_for_uri(aURI,
                                aGUID) {
-  let caller = Components.stack.caller;
-  let guid = do_get_guid_for_uri(aURI, caller);
+  let guid = do_get_guid_for_uri(aURI);
   if (aGUID) {
-    do_check_valid_places_guid(aGUID, caller);
-    Assert.equal(guid, aGUID, caller);
+    do_check_valid_places_guid(aGUID);
+    Assert.equal(guid, aGUID, "Should have a guid in moz_places for the URI");
   }
 }
 
 /**
  * Retrieves the guid for a given bookmark.
  *
  * @param aId
  *        The bookmark id to check.
  * @param [optional] aStack
  *        The stack frame used to report the error.
  * @return the associated the guid.
  */
-function do_get_guid_for_bookmark(aId,
-                                  aStack) {
-  if (!aStack) {
-    aStack = Components.stack.caller;
-  }
+function do_get_guid_for_bookmark(aId) {
   let stmt = DBConn().createStatement(
     `SELECT guid
      FROM moz_bookmarks
      WHERE id = :item_id`
   );
   stmt.params.item_id = aId;
-  Assert.ok(stmt.executeStep(), aStack);
+  Assert.ok(stmt.executeStep(), "Should succeed executing the SQL statement");
   let guid = stmt.row.guid;
   stmt.finalize();
-  do_check_valid_places_guid(guid, aStack);
+  do_check_valid_places_guid(guid);
   return guid;
 }
 
 /**
  * Tests that a guid was set in moz_places for a given bookmark.
  *
  * @param aId
  *        The bookmark id to check.
  * @param [optional] aGUID
  *        The expected guid in the database.
  */
 function do_check_guid_for_bookmark(aId,
                                     aGUID) {
-  let caller = Components.stack.caller;
-  let guid = do_get_guid_for_bookmark(aId, caller);
+  let guid = do_get_guid_for_bookmark(aId);
   if (aGUID) {
-    do_check_valid_places_guid(aGUID, caller);
-    Assert.equal(guid, aGUID, caller);
+    do_check_valid_places_guid(aGUID);
+    Assert.equal(guid, aGUID, "Should have the correct GUID for the bookmark");
   }
 }
 
 /**
  * Compares 2 arrays returning whether they contains the same elements.
  *
  * @param a1
  *        First array to compare.
--- a/toolkit/components/places/tests/history/test_async_history_api.js
+++ b/toolkit/components/places/tests/history/test_async_history_api.js
@@ -124,25 +124,24 @@ VisitObserver.prototype = {
  *
  * @param aURI
  *        The uri to check.
  * @param aTitle
  *        The expected title in the database.
  */
 function do_check_title_for_uri(aURI,
                                 aTitle) {
-  let stack = Components.stack.caller;
   let stmt = DBConn().createStatement(
     `SELECT title
      FROM moz_places
      WHERE url_hash = hash(:url) AND url = :url`
   );
   stmt.params.url = aURI.spec;
-  Assert.ok(stmt.executeStep(), stack);
-  Assert.equal(stmt.row.title, aTitle, stack);
+  Assert.ok(stmt.executeStep());
+  Assert.equal(stmt.row.title, aTitle);
   stmt.finalize();
 }
 
 // Test Functions
 
 add_task(async function test_interface_exists() {
   let history = Cc["@mozilla.org/browser/history;1"].getService(Ci.nsISupports);
   Assert.ok(history instanceof Ci.mozIAsyncHistory);