Backed out changeset a4cc519364b5 (bug 1100294)

This commit is contained in:
Wes Kocher 2015-03-26 14:30:20 -07:00
parent 298f693d17
commit a61d9a9525
5 changed files with 71 additions and 59 deletions

View File

@ -77,20 +77,21 @@ add_task(function* database_is_valid() {
add_task(function* test_keywords() {
// When 2 urls have the same keyword, if one has postData it will be
// preferred.
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");
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");
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

View File

@ -65,13 +65,13 @@ add_task(function* database_is_valid() {
add_task(function* test_keywords() {
// When 2 urls have the same keyword, if one has postData it will be
// preferred.
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 [ 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);
});

View File

@ -0,0 +1,30 @@
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);
}

View File

@ -717,45 +717,25 @@ add_test(function test_sort_folder_by_name() {
});
add_test(function test_edit_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;
}
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);
yield new Promise(resolve => do_timeout(100, resolve));
}
}
txn.doTransaction();
let [url, post_data] = PlacesUtils.getURLAndPostDataForKeyword("kw");
Assert.equal(url, testURI.spec);
Assert.equal(postData, post_data);
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.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 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"
});
let testBkmId = yield PlacesUtils.promiseItemId(testBkm.guid);
let txn = new PlacesEditBookmarkPostDataTransaction(testBkmId, postData);
txn.doTransaction();
yield promiseKeyword("kw", testURI.spec, postData);
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);
run_next_test();
});
add_test(function test_tagURI_untagURI() {

View File

@ -23,6 +23,7 @@ skip-if = os == "android"
[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]