mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1100294 - Remove remaining uses of PlacesUtils.getURLAndPostDataForKeyword() from tests r=mak
This commit is contained in:
parent
99d1a0761d
commit
b344a1a003
@ -77,21 +77,20 @@ 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 [ 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
|
||||
|
@ -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 [ 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);
|
||||
});
|
||||
|
@ -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);
|
||||
}
|
@ -717,25 +717,45 @@ add_test(function test_sort_folder_by_name() {
|
||||
});
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
txn.doTransaction();
|
||||
let [url, post_data] = PlacesUtils.getURLAndPostDataForKeyword("kw");
|
||||
Assert.equal(url, testURI.spec);
|
||||
Assert.equal(postData, post_data);
|
||||
yield new Promise(resolve => do_timeout(100, resolve));
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
Task.spawn(function* () {
|
||||
const POST_DATA_ANNO = "bookmarkProperties/POSTData";
|
||||
let postData = "post-test_edit_postData";
|
||||
let testURI = NetUtil.newURI("http://test_edit_postData.com");
|
||||
|
||||
run_next_test();
|
||||
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);
|
||||
});
|
||||
|
||||
add_test(function test_tagURI_untagURI() {
|
||||
|
@ -23,7 +23,6 @@ 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]
|
||||
|
Loading…
Reference in New Issue
Block a user