Backout 85afe1aa3e6f (bug 1092607) for failures in test_PlacesUtils_asyncGetBookmarkIds.js.
authorMarco Bonardo <mbonardo@mozilla.com>
Mon, 03 Aug 2015 17:34:07 +0200
changeset 287508 07e164fda53fc35c5a4fa3ef2aeb8e19af7377e8
parent 287507 f6f67168e2423a9b539b13794cb1448b1a069b09
child 287509 56f1475f352e05f401d65cc626e14b01f9cb4af4
child 287575 47a42d3aa754a786fd472f089c17b71d1379f57e
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1092607
milestone42.0a1
backs out85afe1aa3e6fa57689fa096a192a4265e0c40d01
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
Backout 85afe1aa3e6f (bug 1092607) for failures in test_PlacesUtils_asyncGetBookmarkIds.js.
toolkit/components/places/tests/unit/test_PlacesUtils_asyncGetBookmarkIds.js
--- a/toolkit/components/places/tests/unit/test_PlacesUtils_asyncGetBookmarkIds.js
+++ b/toolkit/components/places/tests/unit/test_PlacesUtils_asyncGetBookmarkIds.js
@@ -1,76 +1,86 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
 /**
  * This file tests PlacesUtils.asyncGetBookmarkIds method.
  */
 
 const TEST_URL = "http://www.example.com/";
 
-let promiseAsyncGetBookmarkIds = Task.async(function* (url) {
-  yield PlacesTestUtils.promiseAsyncUpdates();
-  return new Promise(resolve => {
-    PlacesUtils.asyncGetBookmarkIds(url, (itemIds, uri) => {
-      resolve({ itemIds, uri });
+[
+
+  function test_no_bookmark() {
+    PlacesUtils.asyncGetBookmarkIds(TEST_URL, (aItemIds, aURI) => {
+      do_check_eq(aItemIds.length, 0);
+      do_check_eq(aURI, TEST_URL);
+      run_next_test();
     });
-  });
-});
+  },
 
-add_task(function* test_no_bookmark() {
-  let { itemIds, url } = yield promiseAsyncGetBookmarkIds(TEST_URL);
-  Assert.equal(itemIds.length, 0);
-  Assert.equal(url, TEST_URL);
-});
+  function test_one_bookmark_nsIURI() {
+    let uri = NetUtil.newURI(TEST_URL);
+    let itemId = PlacesUtils.bookmarks.insertBookmark(
+      PlacesUtils.unfiledBookmarksFolderId, uri, "test",
+      PlacesUtils.bookmarks.DEFAULT_INDEX
+    );
+    PlacesUtils.asyncGetBookmarkIds(uri, (aItemIds, aURI) => {
+      do_check_eq(aItemIds.length, 1);
+      do_check_eq(aItemIds[0], itemId);
+      do_check_true(aURI.equals(uri));
+      PlacesUtils.bookmarks.removeItem(itemId);
+      run_next_test();
+    });
+  },
 
-add_task(function* test_one_bookmark() {
-  let bookmark = yield PlacesUtils.bookmarks.insert({
-    parentGuid: PlacesUtils.bookmarks.unfiledGuid,
-    url: TEST_URL,
-    title: "test"
-  });
-  let itemId = yield PlacesUtils.promiseItemId(bookmark.guid);
-  {
-    let { itemIds, url } = yield promiseAsyncGetBookmarkIds(NetUtil.newURI(TEST_URL));
-    Assert.equal(itemIds.length, 1);
-    Assert.equal(itemIds[0], itemId);
-    Assert.equal(url.spec, TEST_URL);
-  }
-  {
-    let { itemIds, url } = yield promiseAsyncGetBookmarkIds(TEST_URL);
-    Assert.equal(itemIds.length, 1);
-    Assert.equal(itemIds[0], itemId);
-    Assert.equal(url, TEST_URL);
-  }
-  yield PlacesUtils.bookmarks.remove(bookmark);
-});
+  function test_one_bookmark_spec() {
+    let uri = NetUtil.newURI(TEST_URL);
+    let itemId = PlacesUtils.bookmarks.insertBookmark(
+      PlacesUtils.unfiledBookmarksFolderId, uri, "test",
+      PlacesUtils.bookmarks.DEFAULT_INDEX
+    );
+    PlacesUtils.asyncGetBookmarkIds(TEST_URL, (aItemIds, aURI) => {
+      do_check_eq(aItemIds.length, 1);
+      do_check_eq(aItemIds[0], itemId);
+      do_check_eq(aURI, TEST_URL);
+      PlacesUtils.bookmarks.removeItem(itemId);
+      run_next_test();
+    });
+  },
 
-add_task(function* test_multiple_bookmarks() {
-  let ids = [];
-  let bookmark1 = yield PlacesUtils.bookmarks.insert({
-    parentGuid: PlacesUtils.bookmarks.unfiledGuid,
-    url: TEST_URL,
-    title: "test"
-  });
-  ids.push((yield PlacesUtils.promiseItemId(bookmark1.guid)));
-  let bookmark2 = yield PlacesUtils.bookmarks.insert({
-    parentGuid: PlacesUtils.bookmarks.unfiledGuid,
-    url: TEST_URL,
-    title: "test"
-  });
-  ids.push((yield PlacesUtils.promiseItemId(bookmark2.guid)));
+  function test_multiple_bookmarks() {
+    let uri = NetUtil.newURI(TEST_URL);
+    let itemIds = [];
+    itemIds.push(PlacesUtils.bookmarks.insertBookmark(
+      PlacesUtils.unfiledBookmarksFolderId, uri, "test",
+      PlacesUtils.bookmarks.DEFAULT_INDEX
+    ));
+    itemIds.push(PlacesUtils.bookmarks.insertBookmark(
+      PlacesUtils.unfiledBookmarksFolderId, uri, "test",
+      PlacesUtils.bookmarks.DEFAULT_INDEX
+    ));
+    PlacesUtils.asyncGetBookmarkIds(uri, (aItemIds, aURI) => {
+      do_check_eq(aItemIds.length, 2);
+      do_check_true(do_compare_arrays(itemIds, aItemIds));
+      do_check_true(aURI.equals(uri));
+      itemIds.forEach(PlacesUtils.bookmarks.removeItem);
+      run_next_test();
+    });
+  },
 
-  let { itemIds, url } = yield promiseAsyncGetBookmarkIds(TEST_URL);
-  Assert.deepEqual(ids, itemIds);
-  Assert.equal(url, TEST_URL);
-
-  yield PlacesUtils.bookmarks.remove(bookmark1);
-  yield PlacesUtils.bookmarks.remove(bookmark2);
-});
+  function test_cancel() {
+    let pending = PlacesUtils.asyncGetBookmarkIds(TEST_URL, (aItemIds, aURI) => {
+      do_throw("A canceled pending statement should not be invoked");
+    });
+    pending.cancel();
+    PlacesUtils.asyncGetBookmarkIds(TEST_URL, (aItemIds, aURI) => {
+      do_check_eq(aItemIds.length, 0);
+      do_check_eq(aURI, TEST_URL);
+      run_next_test();
+    });
+  },
 
-add_task(function* test_cancel() {
-  let pending = PlacesUtils.asyncGetBookmarkIds(TEST_URL, () => {
-    Assert.ok(false, "A canceled pending statement should not be invoked");
-  });
-  pending.cancel();
+].forEach(add_test);
 
-  let { itemIds, url } = yield promiseAsyncGetBookmarkIds(TEST_URL);
-  Assert.equal(itemIds.length, 0);
-  Assert.equal(url, TEST_URL);
-});
+function run_test() {
+  run_next_test();
+}