Bug 1100294 - Remove remaining uses of PlacesUtils.getURLAndPostDataForKeyword() from tests r=mak
☠☠ backed out by 280e27c77777 ☠ ☠
authorTim Taubert <ttaubert@mozilla.com>
Thu, 26 Mar 2015 10:02:05 +0100
changeset 266176 a4cc519364b5b1acc8e02f58ae8d3f50e18f97b7
parent 266175 6306a0c0be6597610bffb95a4eac68931f886d5d
child 266177 02974be498e5062124c8b0aa162d886fdc22a966
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1100294
milestone39.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 1100294 - Remove remaining uses of PlacesUtils.getURLAndPostDataForKeyword() from tests r=mak
toolkit/components/places/tests/migration/test_current_from_v26.js
toolkit/components/places/tests/migration/test_current_from_v27.js
toolkit/components/places/tests/unit/test_398914.js
toolkit/components/places/tests/unit/test_placesTxn.js
toolkit/components/places/tests/unit/xpcshell.ini
--- a/toolkit/components/places/tests/migration/test_current_from_v26.js
+++ b/toolkit/components/places/tests/migration/test_current_from_v26.js
@@ -72,28 +72,27 @@ add_task(function* database_is_valid() {
 
   let db = yield PlacesUtils.promiseDBConnection();
   Assert.equal((yield db.getSchemaVersion()), CURRENT_SCHEMA_VERSION);
 });
 
 add_task(function* test_keywords() {
   // When 2 urls have the same keyword, if one has postData it will be
   // preferred.
-  let [ url1, postData1 ] = PlacesUtils.getURLAndPostDataForKeyword("kw1");
-  Assert.equal(url1, "http://test2.com/");
-  Assert.equal(postData1, "postData1");
-  let [ url2, postData2 ] = PlacesUtils.getURLAndPostDataForKeyword("kw2");
-  Assert.equal(url2, "http://test2.com/");
-  Assert.equal(postData2, "postData2");
-  let [ url3, postData3 ] = PlacesUtils.getURLAndPostDataForKeyword("kw3");
-  Assert.equal(url3, "http://test1.com/");
-  Assert.equal(postData3, null);
-  let [ url4, postData4 ] = PlacesUtils.getURLAndPostDataForKeyword("kw4");
-  Assert.equal(url4, null);
-  Assert.equal(postData4, null);
-  let [ url5, postData5 ] = PlacesUtils.getURLAndPostDataForKeyword("kw5");
-  Assert.equal(url5, "http://test3.com/");
-  Assert.equal(postData5, "postData3");
+  let entry1 = yield PlacesUtils.keywords.fetch("kw1");
+  Assert.equal(entry1.url.href, "http://test2.com/");
+  Assert.equal(entry1.postData, "postData1");
+  let entry2 = yield PlacesUtils.keywords.fetch("kw2");
+  Assert.equal(entry2.url.href, "http://test2.com/");
+  Assert.equal(entry2.postData, "postData2");
+  let entry3 = yield PlacesUtils.keywords.fetch("kw3");
+  Assert.equal(entry3.url.href, "http://test1.com/");
+  Assert.equal(entry3.postData, null);
+  let entry4 = yield PlacesUtils.keywords.fetch("kw4");
+  Assert.equal(entry4, null);
+  let entry5 = yield PlacesUtils.keywords.fetch("kw5");
+  Assert.equal(entry5.url.href, "http://test3.com/");
+  Assert.equal(entry5.postData, "postData3");
 
   Assert.equal((yield foreign_count("http://test1.com/")), 5); // 4 bookmark2 + 1 keywords
   Assert.equal((yield foreign_count("http://test2.com/")), 4); // 2 bookmark2 + 2 keywords
   Assert.equal((yield foreign_count("http://test3.com/")), 3); // 2 bookmark2 + 1 keywords
 });
--- a/toolkit/components/places/tests/migration/test_current_from_v27.js
+++ b/toolkit/components/places/tests/migration/test_current_from_v27.js
@@ -60,18 +60,18 @@ add_task(function* database_is_valid() {
 
   let db = yield PlacesUtils.promiseDBConnection();
   Assert.equal((yield db.getSchemaVersion()), CURRENT_SCHEMA_VERSION);
 });
 
 add_task(function* test_keywords() {
   // When 2 urls have the same keyword, if one has postData it will be
   // preferred.
-  let [ url1, postData1 ] = PlacesUtils.getURLAndPostDataForKeyword("kw1");
-  Assert.equal(url1, "http://test2.com/");
-  Assert.equal(postData1, "postData1");
-  let [ url2, postData2 ] = PlacesUtils.getURLAndPostDataForKeyword("kw2");
-  Assert.equal(url2, "http://test2.com/");
-  Assert.equal(postData2, "postData2");
-  let [ url3, postData3 ] = PlacesUtils.getURLAndPostDataForKeyword("kw3");
-  Assert.equal(url3, "http://test1.com/");
-  Assert.equal(postData3, null);
+  let entry1 = yield PlacesUtils.keywords.fetch("kw1");
+  Assert.equal(entry1.url.href, "http://test2.com/");
+  Assert.equal(entry1.postData, "postData1");
+  let entry2 = yield PlacesUtils.keywords.fetch("kw2");
+  Assert.equal(entry2.url.href, "http://test2.com/");
+  Assert.equal(entry2.postData, "postData2");
+  let entry3 = yield PlacesUtils.keywords.fetch("kw3");
+  Assert.equal(entry3.url.href, "http://test1.com/");
+  Assert.equal(entry3.postData, null);
 });
deleted file mode 100644
--- a/toolkit/components/places/tests/unit/test_398914.js
+++ /dev/null
@@ -1,30 +0,0 @@
-function run_test() {
-  var testURI = uri("http://foo.com");
-
-  /*
-  1. Create a bookmark for a URI, with a keyword and post data.
-  2. Create a bookmark for the same URI, with a different keyword and different post data.
-  3. Confirm that our method for getting a URI+postdata retains bookmark affinity.
-  */
-  var bm1 = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarksMenuFolderId, testURI, -1, "blah");
-  PlacesUtils.bookmarks.setKeywordForBookmark(bm1, "foo");
-  PlacesUtils.setPostDataForBookmark(bm1, "pdata1");
-  var bm2 = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarksMenuFolderId, testURI, -1, "blah");
-  PlacesUtils.bookmarks.setKeywordForBookmark(bm2, "bar");
-  PlacesUtils.setPostDataForBookmark(bm2, "pdata2");
-
-  // check kw, pd for bookmark 1
-  var url, postdata;
-  [url, postdata] = PlacesUtils.getURLAndPostDataForKeyword("foo");
-  do_check_eq(testURI.spec, url);
-  do_check_eq(postdata, "pdata1");
-
-  // check kw, pd for bookmark 2
-  [url, postdata] = PlacesUtils.getURLAndPostDataForKeyword("bar");
-  do_check_eq(testURI.spec, url);
-  do_check_eq(postdata, "pdata2");
-
-  // cleanup
-  PlacesUtils.bookmarks.removeItem(bm1);
-  PlacesUtils.bookmarks.removeItem(bm2);
-}
--- a/toolkit/components/places/tests/unit/test_placesTxn.js
+++ b/toolkit/components/places/tests/unit/test_placesTxn.js
@@ -712,35 +712,55 @@ add_test(function test_sort_folder_by_na
   do_check_eq(0, bmsvc.getItemIndex(b1));
   do_check_eq(1, bmsvc.getItemIndex(b2));
   do_check_eq(2, bmsvc.getItemIndex(b3));
 
   run_next_test();
 });
 
 add_test(function test_edit_postData() {
-  const POST_DATA_ANNO = "bookmarkProperties/POSTData";
-  let postData = "post-test_edit_postData";
-  let testURI = NetUtil.newURI("http://test_edit_postData.com");
-  let testBkmId = bmsvc.insertBookmark(root, testURI, bmsvc.DEFAULT_INDEX, "Test edit Post Data");
-  PlacesUtils.bookmarks.setKeywordForBookmark(testBkmId, "kw");
-  let txn = new PlacesEditBookmarkPostDataTransaction(testBkmId, postData);
+  function* promiseKeyword(keyword, href, postData) {
+    while (true) {
+      let entry = yield PlacesUtils.keywords.fetch(keyword);
+      if (entry && entry.url.href == href && entry.postData == postData) {
+        break;
+      }
+
+      yield new Promise(resolve => do_timeout(100, resolve));
+    }
+  }
+
+  Task.spawn(function* () {
+    const POST_DATA_ANNO = "bookmarkProperties/POSTData";
+    let postData = "post-test_edit_postData";
+    let testURI = NetUtil.newURI("http://test_edit_postData.com");
 
-  txn.doTransaction();
-  let [url, post_data] = PlacesUtils.getURLAndPostDataForKeyword("kw");
-  Assert.equal(url, testURI.spec);
-  Assert.equal(postData, post_data);
+    let testBkm = yield PlacesUtils.bookmarks.insert({
+      parentGuid: PlacesUtils.bookmarks.menuGuid,
+      url: "http://test_edit_postData.com",
+      title: "Test edit Post Data"
+    });
+
+    yield PlacesUtils.keywords.insert({
+      keyword: "kw",
+      url: "http://test_edit_postData.com"
+    });
 
-  txn.undoTransaction();
-  [url, post_data] = PlacesUtils.getURLAndPostDataForKeyword("kw");
-  Assert.equal(url, testURI.spec);
-  // We don't allow anymore to set a null post data.
-  //Assert.equal(null, post_data);
+    let testBkmId = yield PlacesUtils.promiseItemId(testBkm.guid);
+    let txn = new PlacesEditBookmarkPostDataTransaction(testBkmId, postData);
+
+    txn.doTransaction();
+    yield promiseKeyword("kw", testURI.spec, postData);
 
-  run_next_test();
+    txn.undoTransaction();
+    entry = yield PlacesUtils.keywords.fetch("kw");
+    Assert.equal(entry.url.href, testURI.spec);
+    // We don't allow anymore to set a null post data.
+    //Assert.equal(null, post_data);
+  }).then(run_next_test);
 });
 
 add_test(function test_tagURI_untagURI() {
   const TAG_1 = "tag-test_tagURI_untagURI-bar";
   const TAG_2 = "tag-test_tagURI_untagURI-foo";
   let tagURI = NetUtil.newURI("http://test_tagURI_untagURI.com");
 
   // Test tagURI
--- a/toolkit/components/places/tests/unit/xpcshell.ini
+++ b/toolkit/components/places/tests/unit/xpcshell.ini
@@ -18,17 +18,16 @@ support-files =
 [test_317472.js]
 # Bug 676989: test hangs consistently on Android
 skip-if = os == "android"
 [test_331487.js]
 [test_384370.js]
 [test_385397.js]
 # Bug 676989: test fails consistently on Android
 fail-if = os == "android"
-[test_398914.js]
 [test_399264_query_to_string.js]
 [test_399264_string_to_query.js]
 [test_399266.js]
 # Bug 676989: test fails consistently on Android
 fail-if = os == "android"
 # Bug 821781: test fails intermittently on Linux
 skip-if = os == "linux"
 [test_402799.js]