Merge fx-team to m-c. a=merge

This commit is contained in:
Ryan VanderMeulen 2015-03-17 14:10:38 -04:00
commit 74ea6bde99
48 changed files with 857 additions and 966 deletions

View File

@ -455,8 +455,8 @@ loop.contacts = (function(_, mozL10n) {
return;
}
this.props.notifications.successL10n("import_contacts_success_message", {
num: stats.total,
total: stats.total
num: stats.success,
total: stats.success
});
});
},

View File

@ -455,8 +455,8 @@ loop.contacts = (function(_, mozL10n) {
return;
}
this.props.notifications.successL10n("import_contacts_success_message", {
num: stats.total,
total: stats.total
num: stats.success,
total: stats.success
});
});
},

View File

@ -316,7 +316,10 @@ loop.conversationViews = (function(mozL10n) {
* Something went wrong view. Displayed when there's a big problem.
*/
var GenericFailureView = React.createClass({displayName: "GenericFailureView",
mixins: [sharedMixins.AudioMixin],
mixins: [
sharedMixins.AudioMixin,
sharedMixins.DocumentTitleMixin
],
propTypes: {
cancelCall: React.PropTypes.func.isRequired
@ -327,7 +330,7 @@ loop.conversationViews = (function(mozL10n) {
},
render: function() {
document.title = mozL10n.get("generic_failure_title");
this.setTitle(mozL10n.get("generic_failure_title"));
return (
React.createElement("div", {className: "call-window"},

View File

@ -316,7 +316,10 @@ loop.conversationViews = (function(mozL10n) {
* Something went wrong view. Displayed when there's a big problem.
*/
var GenericFailureView = React.createClass({
mixins: [sharedMixins.AudioMixin],
mixins: [
sharedMixins.AudioMixin,
sharedMixins.DocumentTitleMixin
],
propTypes: {
cancelCall: React.PropTypes.func.isRequired
@ -327,7 +330,7 @@ loop.conversationViews = (function(mozL10n) {
},
render: function() {
document.title = mozL10n.get("generic_failure_title");
this.setTitle(mozL10n.get("generic_failure_title"));
return (
<div className="call-window">

View File

@ -269,7 +269,7 @@ describe("loop.contacts", function() {
it("should notify the end user from a succesful import", function() {
sandbox.stub(notifications, "successL10n");
navigator.mozLoop.startImport = function(opts, cb) {
cb(null, {total: 42});
cb(null, {success: 42});
};
listView.handleImportButtonClick();

View File

@ -8,7 +8,7 @@ describe("loop.conversationViews", function () {
var sharedUtils = loop.shared.utils;
var sharedView = loop.shared.views;
var sandbox, oldTitle, view, dispatcher, contact, fakeAudioXHR;
var sandbox, view, dispatcher, contact, fakeAudioXHR;
var fakeMozLoop, fakeWindow;
var CALL_STATES = loop.store.CALL_STATES;
@ -33,7 +33,6 @@ describe("loop.conversationViews", function () {
sandbox = sinon.sandbox.create();
sandbox.useFakeTimers();
oldTitle = document.title;
sandbox.stub(document.mozL10n, "get", function(x) {
return x;
});
@ -106,7 +105,6 @@ describe("loop.conversationViews", function () {
afterEach(function() {
loop.shared.mixins.setRootObject(window);
document.title = oldTitle;
view = undefined;
delete navigator.mozLoop;
sandbox.restore();
@ -912,5 +910,8 @@ describe("loop.conversationViews", function () {
expect(fakeAudio.loop).to.equal(false);
});
it("should set the title to generic_failure_title", function() {
expect(fakeWindow.document.title).eql("generic_failure_title");
});
});
});

View File

@ -130,7 +130,7 @@ describe("loop.conversation", function() {
});
describe("AppControllerView", function() {
var conversationStore, client, ccView, oldTitle, dispatcher;
var conversationStore, client, ccView, dispatcher;
var conversationAppStore, roomStore;
function mountTestComponent() {
@ -142,7 +142,6 @@ describe("loop.conversation", function() {
}
beforeEach(function() {
oldTitle = document.title;
client = new loop.Client();
dispatcher = new loop.Dispatcher();
conversationStore = new loop.store.ConversationStore(
@ -177,7 +176,6 @@ describe("loop.conversation", function() {
afterEach(function() {
ccView = undefined;
document.title = oldTitle;
});
it("should display the CallControllerView for outgoing calls", function() {

View File

@ -125,7 +125,7 @@ function CheckLockState() {
}, e => console.error(e));
} catch(e) {
// Exception. pref actor is only accessible if forbird-certified-apps is false
devtoolsCheckResult.textContent = sYes;
devtoolsCheckResult.textContent = sNo;
flipCertPerfAction.removeAttribute("hidden");
}

View File

@ -49,7 +49,7 @@ window.addEventListener("load", function onLoad() {
window.addEventListener("unload", function onUnload() {
window.removeEventListener("unload", onUnload);
UI.uninit();
UI.destroy();
});
let projectList;
@ -118,10 +118,10 @@ let UI = {
gDevToolsBrowser.isWebIDEInitialized.resolve();
},
uninit: function() {
destroy: function() {
window.removeEventListener("focus", this.onfocus, true);
AppManager.off("app-manager-update", this.appManagerUpdate);
AppManager.uninit();
AppManager.destroy();
projectList = null;
window.removeEventListener("message", this.onMessage);
this.updateConnectionTelemetry();
@ -186,6 +186,7 @@ let UI = {
case "project-is-running":
case "list-tabs-response":
this.updateCommands();
projectList.update();
break;
case "runtime-details":
this.updateRuntimeButton();

View File

@ -34,7 +34,14 @@ let AppManager = exports.AppManager = {
DEFAULT_PROJECT_ICON: "chrome://browser/skin/devtools/app-manager/default-app-icon.png",
DEFAULT_PROJECT_NAME: "--",
_initialized: false,
init: function() {
if (this._initialized) {
return;
}
this._initialized = true;
let port = Services.prefs.getIntPref("devtools.debugger.remote-port");
this.connection = ConnectionManager.createConnection("localhost", port);
this.onConnectionChanged = this.onConnectionChanged.bind(this);
@ -57,7 +64,12 @@ let AppManager = exports.AppManager = {
this._telemetry = new Telemetry();
},
uninit: function() {
destroy: function() {
if (!this._initialized) {
return;
}
this._initialized = false;
this.selectedProject = null;
this.selectedRuntime = null;
RuntimeScanners.off("runtime-list-updated", this._rebuildRuntimeList);

View File

@ -28,6 +28,8 @@ module.exports = ProjectList = function(window, parentWindow) {
this._panelNodeEl = "div";
}
AppManager.init();
return this;
};

View File

@ -186,11 +186,16 @@ add_task(function test_setup()
"goog-badbinurl-shavar");
Services.prefs.setCharPref("urlclassifier.downloadAllowTable",
"goog-downloadwhite-digest256");
// On Windows SendRemoteQueryInternal needs locale preference.
let locale = Services.prefs.getCharPref("general.useragent.locale");
Services.prefs.setCharPref("general.useragent.locale", "en-US");
do_register_cleanup(function() {
Services.prefs.clearUserPref("browser.safebrowsing.malware.enabled");
Services.prefs.clearUserPref("browser.safebrowsing.downloads.enabled");
Services.prefs.clearUserPref("urlclassifier.downloadBlockTable");
Services.prefs.clearUserPref("urlclassifier.downloadAllowTable");
Services.prefs.setCharPref("general.useragent.locale", locale);
});
gHttpServer = new HttpServer();

View File

@ -1,7 +1,6 @@
[DEFAULT]
head = head_download_manager.js
tail = tail_download_manager.js
firefox-appdir = browser
skip-if = toolkit == 'android' || toolkit == 'gonk'
support-files =
downloads_manifest.js

View File

@ -12,8 +12,7 @@ const TOPIC_AUTOCOMPLETE_FEEDBACK_INCOMING = "autocomplete-will-enter-text";
/**
* Ensures that we have no data in the tables created by ANALYZE.
*/
function clearAnalyzeData()
{
function clearAnalyzeData() {
let db = DBConn();
if (!db.tableExists("sqlite_stat1")) {
return;
@ -29,8 +28,7 @@ function clearAnalyzeData()
* @param aRan
* True if it was expected to run, false otherwise
*/
function do_check_analyze_ran(aTableName, aRan)
{
function do_check_analyze_ran(aTableName, aRan) {
let db = DBConn();
do_check_true(db.tableExists("sqlite_stat1"));
let stmt = db.createStatement("SELECT idx FROM sqlite_stat1 WHERE tbl = :table");
@ -52,18 +50,19 @@ function do_check_analyze_ran(aTableName, aRan)
////////////////////////////////////////////////////////////////////////////////
//// Tests
function run_test()
{
function run_test() {
run_next_test();
}
add_task(function init_tests()
{
add_task(function* init_tests() {
const TEST_URI = NetUtil.newURI("http://mozilla.org/");
const TEST_TITLE = "This is a test";
let bs = PlacesUtils.bookmarks;
bs.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, TEST_URI,
bs.DEFAULT_INDEX, TEST_TITLE);
yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
title: TEST_TITLE,
url: TEST_URI
});
yield PlacesTestUtils.addVisits(TEST_URI);
let thing = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAutoCompleteInput,
@ -80,8 +79,7 @@ add_task(function init_tests()
null);
});
add_task(function test_timed()
{
add_task(function* test_timed() {
clearAnalyzeData();
// Set a low interval and wait for the timed expiration to start.
@ -96,8 +94,7 @@ add_task(function test_timed()
do_check_analyze_ran("moz_inputhistory", true);
});
add_task(function test_debug()
{
add_task(function* test_debug() {
clearAnalyzeData();
yield promiseForceExpirationStep(1);
@ -108,8 +105,7 @@ add_task(function test_debug()
do_check_analyze_ran("moz_inputhistory", true);
});
add_task(function test_clear_history()
{
add_task(function* test_clear_history() {
clearAnalyzeData();
let promise = promiseTopicObserved(PlacesUtils.TOPIC_EXPIRATION_FINISHED);

View File

@ -12,8 +12,6 @@
* This expiration policy is only valid for page annotations.
*/
let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
let as = Cc["@mozilla.org/browser/annotation-service;1"].
getService(Ci.nsIAnnotationService);
@ -47,8 +45,11 @@ add_task(function test_annos_expire_history() {
let pageURI = uri("http://item_anno." + i + ".mozilla.org/");
// We also add a visit before bookmarking.
yield PlacesTestUtils.addVisits({ uri: pageURI, visitDate: now++ });
let id = bs.insertBookmark(bs.unfiledBookmarksFolder, pageURI,
bs.DEFAULT_INDEX, null);
yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: pageURI,
title: null
});
// Notice we use page annotations here, items annotations can't use this
// kind of expiration policy.
as.setPageAnnotation(pageURI, "item_persist1", "test", 0, as.EXPIRE_WITH_HISTORY);

View File

@ -15,8 +15,6 @@
* the item is removed, thus expiration won't handle this case at all.
*/
let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
let as = Cc["@mozilla.org/browser/annotation-service;1"].
getService(Ci.nsIAnnotationService);
@ -50,8 +48,12 @@ add_task(function test_annos_expire_never() {
let pageURI = uri("http://item_anno." + i + ".mozilla.org/");
// We also add a visit before bookmarking.
yield PlacesTestUtils.addVisits({ uri: pageURI, visitDate: now++ });
let id = bs.insertBookmark(bs.unfiledBookmarksFolder, pageURI,
bs.DEFAULT_INDEX, null);
let bm = yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: pageURI,
title: null
});
let id = yield PlacesUtils.promiseItemId(bm.guid);
as.setItemAnnotation(id, "item_persist1", "test", 0, as.EXPIRE_NEVER);
as.setItemAnnotation(id, "item_persist2", "test", 0, as.EXPIRE_NEVER);
}

View File

@ -14,8 +14,6 @@
* - EXPIRE_MONTHS: annotation would be expired after 180 days
*/
let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
let as = Cc["@mozilla.org/browser/annotation-service;1"].
getService(Ci.nsIAnnotationService);
@ -89,8 +87,12 @@ add_task(function test_annos_expire_policy() {
for (let i = 0; i < 5; i++) {
let pageURI = uri("http://item_anno." + i + ".mozilla.org/");
yield PlacesTestUtils.addVisits({ uri: pageURI, visitDate: now++ });
let id = bs.insertBookmark(bs.unfiledBookmarksFolder, pageURI,
bs.DEFAULT_INDEX, null);
let bm = yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: pageURI,
title: null
});
let id = yield PlacesUtils.promiseItemId(bm.guid);
// Add a 6 days old anno.
add_old_anno(id, "persist_days", "test", as.EXPIRE_DAYS, 6);
// Add a 8 days old anno, modified 5 days ago.

View File

@ -10,8 +10,6 @@
* Session annotations should be expired when browsing session ends.
*/
let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
let as = Cc["@mozilla.org/browser/annotation-service;1"].
getService(Ci.nsIAnnotationService);
@ -35,8 +33,12 @@ add_task(function test_annos_expire_session() {
// Add some bookmarked page and a couple session annotations for each.
for (let i = 0; i < 10; i++) {
let pageURI = uri("http://session_item_anno." + i + ".mozilla.org/");
let id = bs.insertBookmark(bs.unfiledBookmarksFolder, pageURI,
bs.DEFAULT_INDEX, null);
let bm = yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: pageURI,
title: null
});
let id = yield PlacesUtils.promiseItemId(bm.guid);
as.setItemAnnotation(id, "test1", "test", 0, as.EXPIRE_SESSION);
as.setItemAnnotation(id, "test2", "test", 0, as.EXPIRE_SESSION);
}

View File

@ -12,7 +12,6 @@
*/
let hs = PlacesUtils.history;
let bs = PlacesUtils.bookmarks;
let as = PlacesUtils.annotations;
/**
@ -94,8 +93,12 @@ add_task(function test_historyClear() {
let pageURI = uri("http://item_anno." + i + ".mozilla.org/");
// This visit will be expired.
yield PlacesTestUtils.addVisits({ uri: pageURI });
let id = bs.insertBookmark(bs.unfiledBookmarksFolder, pageURI,
bs.DEFAULT_INDEX, null);
let bm = yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: pageURI,
title: null
});
let id = yield PlacesUtils.promiseItemId(bm.guid);
// Will persist because it's an EXPIRE_NEVER item anno.
as.setItemAnnotation(id, "persist", "test", 0, as.EXPIRE_NEVER);
// Will persist because the page is bookmarked.
@ -140,17 +143,15 @@ add_task(function test_historyClear() {
do_check_eq(items.length, 0);
});
["persist"].forEach(function(aAnno) {
let pages = as.getPagesWithAnnotation(aAnno);
do_check_eq(pages.length, 5);
});
let pages = as.getPagesWithAnnotation("persist");
do_check_eq(pages.length, 5);
["persist"].forEach(function(aAnno) {
let items = as.getItemsWithAnnotation(aAnno);
do_check_eq(items.length, 5);
items.forEach(function(aItemId) {
// Check item exists.
bs.getItemIndex(aItemId);
});
});
let items = as.getItemsWithAnnotation("persist");
do_check_eq(items.length, 5);
for (let itemId of items) {
// Check item exists.
let guid = yield PlacesUtils.promiseItemGuid(itemId);
do_check_true((yield PlacesUtils.bookmarks.fetch({guid})), "item exists");
}
});

View File

@ -10,7 +10,7 @@
let gNow = getExpirablePRTime();
add_task(function test_expire_orphans()
add_task(function* test_expire_orphans()
{
// Add visits to 2 pages and force a orphan expiration. Visits should survive.
yield PlacesTestUtils.addVisits({
@ -22,10 +22,12 @@ add_task(function test_expire_orphans()
visitDate: gNow++
});
// Create a orphan place.
let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI("http://page3.mozilla.org/"),
PlacesUtils.bookmarks.DEFAULT_INDEX, "");
PlacesUtils.bookmarks.removeItem(id);
let bm = yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "http://page3.mozilla.org/",
title: ""
});
yield PlacesUtils.bookmarks.remove(bm);
// Expire now.
yield promiseForceExpirationStep(0);
@ -39,7 +41,7 @@ add_task(function test_expire_orphans()
yield PlacesTestUtils.clearHistory();
});
add_task(function test_expire_orphans_optionalarg()
add_task(function* test_expire_orphans_optionalarg()
{
// Add visits to 2 pages and force a orphan expiration. Visits should survive.
yield PlacesTestUtils.addVisits({
@ -51,10 +53,12 @@ add_task(function test_expire_orphans_optionalarg()
visitDate: gNow++
});
// Create a orphan place.
let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI("http://page3.mozilla.org/"),
PlacesUtils.bookmarks.DEFAULT_INDEX, "");
PlacesUtils.bookmarks.removeItem(id);
let bm = yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "http://page3.mozilla.org/",
title: ""
});
yield PlacesUtils.bookmarks.remove(bm);
// Expire now.
yield promiseForceExpirationStep();

View File

@ -12,8 +12,6 @@
let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
let tests = [
@ -70,8 +68,11 @@ add_task(function test_notifications_onDeleteURI() {
currentTest.bookmarks = [];
for (let i = 0; i < currentTest.addBookmarks; i++) {
let page = "http://" + testIndex + "." + i + ".mozilla.org/";
bs.insertBookmark(bs.unfiledBookmarksFolder, uri(page),
bs.DEFAULT_INDEX, null);
yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
title: null,
url: page
});
currentTest.bookmarks.push(page);
}
@ -103,11 +104,11 @@ add_task(function test_notifications_onDeleteURI() {
currentTest.expectedNotifications);
// Clean up.
bs.removeFolderChildren(bs.unfiledBookmarksFolder);
yield PlacesUtils.bookmarks.eraseEverything();
yield PlacesTestUtils.clearHistory();
}
clearMaxPages();
bs.removeFolderChildren(bs.unfiledBookmarksFolder);
yield PlacesUtils.bookmarks.eraseEverything();
yield PlacesTestUtils.clearHistory();
});

View File

@ -13,8 +13,6 @@
let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
let tests = [
@ -89,8 +87,11 @@ add_task(function test_notifications_onDeleteVisits() {
currentTest.bookmarks = [];
for (let i = 0; i < currentTest.addBookmarks; i++) {
let page = "http://" + testIndex + "." + i + ".mozilla.org/";
bs.insertBookmark(bs.unfiledBookmarksFolder, uri(page),
bs.DEFAULT_INDEX, null);
yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
title: null,
url: page
});
currentTest.bookmarks.push(page);
}
@ -125,11 +126,11 @@ add_task(function test_notifications_onDeleteVisits() {
currentTest.expectedNotifications);
// Clean up.
bs.removeFolderChildren(bs.unfiledBookmarksFolder);
yield PlacesUtils.bookmarks.eraseEverything();
yield PlacesTestUtils.clearHistory();
}
clearMaxPages();
bs.removeFolderChildren(bs.unfiledBookmarksFolder);
yield PlacesUtils.bookmarks.eraseEverything();
yield PlacesTestUtils.clearHistory();
});

View File

@ -95,3 +95,11 @@ function checkFaviconMissingForPage(aPageURI, aCallback) {
aCallback();
});
}
function promiseFaviconMissingForPage(aPageURI) {
return new Promise(resolve => checkFaviconMissingForPage(aPageURI, resolve));
}
function promiseFaviconChanged(aExpectedPageURI, aExpectedFaviconURI) {
return new Promise(resolve => waitForFaviconChanged(aExpectedPageURI, aExpectedFaviconURI, resolve));
}

View File

@ -1,54 +1,41 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* This file tests that favicons are correctly expired by expireAllFavicons.
*/
////////////////////////////////////////////////////////////////////////////////
/// Globals
"use strict";
const TEST_PAGE_URI = NetUtil.newURI("http://example.com/");
const BOOKMARKED_PAGE_URI = NetUtil.newURI("http://example.com/bookmarked");
////////////////////////////////////////////////////////////////////////////////
/// Tests
add_task(function* test_expireAllFavicons() {
const {FAVICON_LOAD_NON_PRIVATE} = PlacesUtils.favicons;
// Add a visited page.
yield PlacesTestUtils.addVisits({ uri: TEST_PAGE_URI, transition: TRANSITION_TYPED });
// Set a favicon for our test page.
yield promiseSetIconForPage(TEST_PAGE_URI, SMALLPNG_DATA_URI);
// Add a page with a bookmark.
yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
url: BOOKMARKED_PAGE_URI,
title: "Test bookmark"
});
// Set a favicon for our bookmark.
yield promiseSetIconForPage(BOOKMARKED_PAGE_URI, SMALLPNG_DATA_URI);
// Start expiration only after data has been saved in the database.
let promise = promiseTopicObserved(PlacesUtils.TOPIC_FAVICONS_EXPIRED);
PlacesUtils.favicons.expireAllFavicons();
yield promise;
// Check that the favicons for the pages we added were removed.
yield promiseFaviconMissingForPage(TEST_PAGE_URI);
yield promiseFaviconMissingForPage(BOOKMARKED_PAGE_URI);
});
function run_test() {
run_next_test();
}
add_test(function test_expireAllFavicons() {
// Set up an observer to wait for favicons expiration to finish.
Services.obs.addObserver(function EAF_observer(aSubject, aTopic, aData) {
Services.obs.removeObserver(EAF_observer, aTopic);
// Check that the favicons for the pages we added were removed.
checkFaviconMissingForPage(TEST_PAGE_URI, function () {
checkFaviconMissingForPage(BOOKMARKED_PAGE_URI, function () {
run_next_test();
});
});
}, PlacesUtils.TOPIC_FAVICONS_EXPIRED, false);
// Add a visited page.
PlacesTestUtils.addVisits({ uri: TEST_PAGE_URI, transition: TRANSITION_TYPED }).then(
function () {
PlacesUtils.favicons.setAndFetchFaviconForPage(TEST_PAGE_URI,
SMALLPNG_DATA_URI, true,
PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE);
// Add a page with a bookmark.
PlacesUtils.bookmarks.insertBookmark(
PlacesUtils.toolbarFolderId, BOOKMARKED_PAGE_URI,
PlacesUtils.bookmarks.DEFAULT_INDEX,
"Test bookmark");
PlacesUtils.favicons.setAndFetchFaviconForPage(
BOOKMARKED_PAGE_URI, SMALLPNG_DATA_URI, true,
PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
function () {
// Start expiration only after data has been saved in the database.
PlacesUtils.favicons.expireAllFavicons();
});
});
});

View File

@ -1,32 +1,19 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test for bug 451499 <https://bugzilla.mozilla.org/show_bug.cgi?id=451499>:
* Wrong folder icon appears on smart bookmarks.
*/
////////////////////////////////////////////////////////////////////////////////
/// Globals
"use strict";
const PAGE_URI = NetUtil.newURI("http://example.com/test_query_result");
////////////////////////////////////////////////////////////////////////////////
/// Tests
function run_test()
{
run_next_test();
}
add_test(function test_query_result_favicon_changed_on_child()
{
add_task(function* test_query_result_favicon_changed_on_child() {
// Bookmark our test page, so it will appear in the query resultset.
let testBookmark = PlacesUtils.bookmarks.insertBookmark(
PlacesUtils.bookmarksMenuFolderId,
PAGE_URI,
PlacesUtils.bookmarks.DEFAULT_INDEX,
"test_bookmark");
let testBookmark = yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.menuGuid,
title: "test_bookmark",
url: PAGE_URI
});
// Get the last 10 bookmarks added to the menu or the toolbar.
let query = PlacesUtils.history.getNewQuery();
@ -42,9 +29,7 @@ add_test(function test_query_result_favicon_changed_on_child()
let result = PlacesUtils.history.executeQuery(query, options);
let resultObserver = {
__proto__: NavHistoryResultObserver.prototype,
containerStateChanged: function QRFCOC_containerStateChanged(aContainerNode,
aOldState,
aNewState) {
containerStateChanged(aContainerNode, aOldState, aNewState) {
if (aNewState == Ci.nsINavHistoryContainerResultNode.STATE_OPENED) {
// We set a favicon on PAGE_URI while the container is open. The
// favicon for the page must have data associated with it in order for
@ -56,30 +41,32 @@ add_test(function test_query_result_favicon_changed_on_child()
PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE);
}
},
nodeIconChanged: function QRFCOC_nodeIconChanged(aNode) {
nodeIconChanged(aNode) {
do_throw("The icon should be set only for the page," +
" not for the containing query.");
}
};
result.addObserver(resultObserver, false);
waitForFaviconChanged(PAGE_URI, SMALLPNG_DATA_URI,
function QRFCOC_faviconChanged() {
// We must wait for the asynchronous database thread to finish the
// operation, and then for the main thread to process any pending
// notifications that came from the asynchronous thread, before we can be
// sure that nodeIconChanged was not invoked in the meantime.
PlacesTestUtils.promiseAsyncUpdates().then(function QRFCOC_asyncUpdates() {
do_execute_soon(function QRFCOC_soon() {
result.removeObserver(resultObserver);
// Free the resources immediately.
result.root.containerOpen = false;
run_next_test();
});
});
});
// Open the container and wait for containerStateChanged.
// Open the container and wait for containerStateChanged. We should start
// observing before setting |containerOpen| as that's caused by the
// setAndFetchFaviconForPage() call caused by the containerStateChanged
// observer above.
let promise = promiseFaviconChanged(PAGE_URI, SMALLPNG_DATA_URI);
result.root.containerOpen = true;
yield promise;
// We must wait for the asynchronous database thread to finish the
// operation, and then for the main thread to process any pending
// notifications that came from the asynchronous thread, before we can be
// sure that nodeIconChanged was not invoked in the meantime.
yield PlacesTestUtils.promiseAsyncUpdates();
result.removeObserver(resultObserver);
// Free the resources immediately.
result.root.containerOpen = false;
});
function run_test() {
run_next_test();
}

View File

@ -41,8 +41,7 @@ const olderthansixmonths = today - (DAY_MICROSEC * 31 * 7);
*/
function task_populateDB(aArray)
{
// Iterate over aArray and execute all the instructions that can be done with
// asynchronous APIs, excluding those that will be done in batch mode later.
// Iterate over aArray and execute all instructions.
for ([, data] in Iterator(aArray)) {
try {
// make the data object into a query data object in order to create proper
@ -101,103 +100,96 @@ function task_populateDB(aArray)
title: qdata.title
});
}
if (qdata.markPageAsTyped) {
PlacesUtils.history.markPageAsTyped(uri(qdata.uri));
}
if (qdata.isPageAnnotation) {
if (qdata.removeAnnotation)
PlacesUtils.annotations.removePageAnnotation(uri(qdata.uri),
qdata.annoName);
else {
PlacesUtils.annotations.setPageAnnotation(uri(qdata.uri),
qdata.annoName,
qdata.annoVal,
qdata.annoFlags,
qdata.annoExpiration);
}
}
if (qdata.isItemAnnotation) {
if (qdata.removeAnnotation)
PlacesUtils.annotations.removeItemAnnotation(qdata.itemId,
qdata.annoName);
else {
PlacesUtils.annotations.setItemAnnotation(qdata.itemId,
qdata.annoName,
qdata.annoVal,
qdata.annoFlags,
qdata.annoExpiration);
}
}
if (qdata.isFolder) {
yield PlacesUtils.bookmarks.insert({
parentGuid: (yield PlacesUtils.promiseItemGuid(qdata.parentFolder)),
type: PlacesUtils.bookmarks.TYPE_FOLDER,
title: qdata.title,
index: qdata.index
});
}
if (qdata.isLivemark) {
PlacesUtils.livemarks.addLivemark({ title: qdata.title
, parentId: qdata.parentFolder
, index: qdata.index
, feedURI: uri(qdata.feedURI)
, siteURI: uri(qdata.uri)
}).then(null, do_throw);
}
if (qdata.isBookmark) {
let data = {
parentGuid: (yield PlacesUtils.promiseItemGuid(qdata.parentFolder)),
index: qdata.index,
title: qdata.title,
url: qdata.uri
};
if (qdata.dateAdded) {
data.dateAdded = new Date(qdata.dateAdded / 1000);
}
if (qdata.lastModified) {
data.lastModified = new Date(qdata.lastModified / 1000);
}
let item = yield PlacesUtils.bookmarks.insert(data);
if (qdata.keyword) {
let itemId = yield PlacesUtils.promiseItemId(item.guid);
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, qdata.keyword);
}
}
if (qdata.isTag) {
PlacesUtils.tagging.tagURI(uri(qdata.uri), qdata.tagArray);
}
if (qdata.isSeparator) {
yield PlacesUtils.bookmarks.insert({
parentGuid: (yield PlacesUtils.promiseItemGuid(qdata.parentFolder)),
type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
index: qdata.index
});
}
} catch (ex) {
// use the data object here in case instantiation of qdata failed
LOG("Problem with this URI: " + data.uri);
do_throw("Error creating database: " + ex + "\n");
}
}
// Now execute the part of the instructions made with synchronous APIs.
PlacesUtils.history.runInBatchMode({
runBatched: function (aUserData)
{
aArray.forEach(function (data)
{
try {
// make the data object into a query data object in order to create proper
// default values for anything left unspecified
var qdata = new queryData(data);
if (qdata.markPageAsTyped) {
PlacesUtils.history.markPageAsTyped(uri(qdata.uri));
}
if (qdata.isPageAnnotation) {
if (qdata.removeAnnotation)
PlacesUtils.annotations.removePageAnnotation(uri(qdata.uri),
qdata.annoName);
else {
PlacesUtils.annotations.setPageAnnotation(uri(qdata.uri),
qdata.annoName,
qdata.annoVal,
qdata.annoFlags,
qdata.annoExpiration);
}
}
if (qdata.isItemAnnotation) {
if (qdata.removeAnnotation)
PlacesUtils.annotations.removeItemAnnotation(qdata.itemId,
qdata.annoName);
else {
PlacesUtils.annotations.setItemAnnotation(qdata.itemId,
qdata.annoName,
qdata.annoVal,
qdata.annoFlags,
qdata.annoExpiration);
}
}
if (qdata.isFolder) {
let folderId = PlacesUtils.bookmarks.createFolder(qdata.parentFolder,
qdata.title,
qdata.index);
}
if (qdata.isLivemark) {
PlacesUtils.livemarks.addLivemark({ title: qdata.title
, parentId: qdata.parentFolder
, index: qdata.index
, feedURI: uri(qdata.feedURI)
, siteURI: uri(qdata.uri)
}).then(null, do_throw);
}
if (qdata.isBookmark) {
let itemId = PlacesUtils.bookmarks.insertBookmark(qdata.parentFolder,
uri(qdata.uri),
qdata.index,
qdata.title);
if (qdata.keyword)
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, qdata.keyword);
if (qdata.dateAdded)
PlacesUtils.bookmarks.setItemDateAdded(itemId, qdata.dateAdded);
if (qdata.lastModified)
PlacesUtils.bookmarks.setItemLastModified(itemId, qdata.lastModified);
}
if (qdata.isTag) {
PlacesUtils.tagging.tagURI(uri(qdata.uri), qdata.tagArray);
}
if (qdata.isDynContainer) {
PlacesUtils.bookmarks.createDynamicContainer(qdata.parentFolder,
qdata.title,
qdata.contractId,
qdata.index);
}
if (qdata.isSeparator)
PlacesUtils.bookmarks.insertSeparator(qdata.parentFolder, qdata.index);
} catch (ex) {
// use the data object here in case instantiation of qdata failed
LOG("Problem with this URI: " + data.uri);
do_throw("Error creating database: " + ex + "\n");
}
}); // End of function and array
}
}, null);
}
@ -241,8 +233,8 @@ function queryData(obj) {
this.index = obj.index ? obj.index : PlacesUtils.bookmarks.DEFAULT_INDEX;
this.isFolder = obj.isFolder ? obj.isFolder : false;
this.contractId = obj.contractId ? obj.contractId : "";
this.lastModified = obj.lastModified ? obj.lastModified : today;
this.dateAdded = obj.dateAdded ? obj.dateAdded : today;
this.lastModified = obj.lastModified ? obj.lastModified : null;
this.dateAdded = obj.dateAdded ? obj.dateAdded : null;
this.keyword = obj.keyword ? obj.keyword : "";
this.visitCount = obj.visitCount ? obj.visitCount : 0;
this.isSeparator = obj.hasOwnProperty("isSeparator") && obj.isSeparator;

View File

@ -1,109 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Pre Test Items go here - Note that if you need time constants or relative
* times, there are several in head_queries.js.
* Other things to do here might be to create some bookmark folders, for access
* to the Places API's you can use the global variables defined in head_queries.js.
* Here is an example of using these to create some bookmark folders:
*/
// Create Folder1 from root
PlacesUtils.bookmarks.createFolder(PlacesUtils.placesRootId, "Folder 1",
PlacesUtils.bookmarks.DEFAULT_INDEX);
var folder1Id = PlacesUtils.bookmarks.getChildFolder(PlacesUtils.placesRootId,
"Folder 1");
// Make Folder 1a a child of Folder 1
PlacesUtils.bookmarks.createFolder(folder1Id, "Folder 1a",
PlacesUtils.bookmarks.DEFAULT_INDEX);
var folder1aId = PlacesUtils.bookmarks.getChildFolder(folder1Id, "Folder 1a");
/**
* The next thing we do is create a test database for us. Each test runs with
* its own database (tail_queries.js will clear it after the run). Take a look
* at the queryData object in head_queries.js, and you'll see how this object
* works. You can call it anything you like, but I usually use "testData".
* I'll include a couple of example entries in the database.
*
* Note that to use the compareArrayToResult API, you need to put all the
* results that are in the query set at the top of the testData list, and those
* results MUST be in the same sort order as the items in the resulting query.
*/
var testData = [
// This puts a history visit item into the database. Note that I don't
// specify the "lastVisit" attribute, because I am ok with "lastVisit"
// defaulting to "today". isInQuery is true as I expect this to turn up in the
// query I'll be doing down below.
{isInQuery: true, isVisit: true, uri: "http://foo.com/"},
// And so on to get a database that has enough elements to adequately test
// the edges of your query set. Be sure to include things that are outside
// the query set but can be updated so that they are included in the query
// set. Here's a more complicated example to finish our examples.
{isInQuery: true, isVisit: true, isDetails: true, title: "taggariffic",
uri: "http://foo.com/tagging/test.html", lastVisit: beginTime, isTag: true,
tagArray: ["moz"] }];
/**
* run_test is where the magic happens. This is automatically run by the test
* harness. It is where you do the work of creating the query, running it, and
* playing with the result set.
*/
function run_test() {
// This function in head_queries.js creates our database with the above data
populateDB(testData);
// Query
var query = PlacesUtils.history.getNewQuery();
// Set query attributes here...
// query options
var options = PlacesUtils.history.getNewQueryOptions();
// Set queryOptions attributes here
// Results - this gets the result set and opens it for reading and modification.
var result = PlacesUtils.history.executeQuery(query, options);
var root = result.root;
root.containerOpen = true;
// You can use this to compare the data in the array with the result set,
// if the array's isInQuery: true items are sorted the same way as the result
// set.
compareArrayToResult(testData, root);
// Make some changes to the result set
// Let's add something first - you can use populateDB to append/update the
// database too...
var addItem = [{isInQuery: true, isVisit: true, isDetails: true, title: "moz",
uri: "http://foo.com/i-am-added.html", lastVisit: jan11_800}];
populateDB(addItem);
// Here's an update
var change1 = [{isDetails: true, uri: "http://foo.com/",
lastVisit: jan12_1730, title: "moz moz mozzie"}];
populateDB(change1);
// Here's a batch update
var updateBatch = {
runBatched: function (aUserData) {
var batchChange = [{isDetails: true, uri: "http://foo.com/changeme2",
title: "moz", lastVisit: jan7_800},
{isPageAnnotation: true, uri: "http://foo.com/begin.html",
annoName: badAnnoName, annoVal: val}];
populateDB(batchChange);
}
};
PlacesUtils.history.runInBatchMode(updateBatch, null);
// Close the container when finished
root.containerOpen = false;
}

View File

@ -22,7 +22,6 @@ var testData = [
uri: "http://bookmarked.com/",
parentFolder: PlacesUtils.toolbarFolderId,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "",
isInQuery: true },
// Add a bookmark that should not be in the results
@ -30,7 +29,6 @@ var testData = [
uri: "http://bookmarked-elsewhere.com/",
parentFolder: PlacesUtils.bookmarksMenuFolderId,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "",
isInQuery: false },
// Add an un-bookmarked visit
@ -86,7 +84,6 @@ add_task(function test_onlyBookmarked()
uri: "http://bookmarked2.com/",
parentFolder: PlacesUtils.toolbarFolderId,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "",
isInQuery: true },
//Add a bookmark that should not show up
@ -94,7 +91,6 @@ add_task(function test_onlyBookmarked()
uri: "http://bookmarked-elsewhere2.com/",
parentFolder: PlacesUtils.bookmarksMenuFolderId,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "",
isInQuery: false }
];

View File

@ -12,12 +12,20 @@ add_task(function* test_queryMultipleFolders() {
let folderIds = [];
let bookmarkIds = [];
for (let i = 0; i < 3; ++i) {
folderIds.push(PlacesUtils.bookmarks.createFolder(PlacesUtils.bookmarksMenuFolderId,
"Folder"+ i, PlacesUtils.bookmarks.DEFAULT_INDEX));
let folder = yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
title: `Folder${i}`
});
folderIds.push(yield PlacesUtils.promiseItemId(folder.guid));
for(let j = 0; j < 7; ++j) {
bookmarkIds.push(PlacesUtils.bookmarks.insertBookmark(folderIds[i],
uri("http://Bookmark" + i + "_" + j + ".com"),
PlacesUtils.bookmarks.DEFAULT_INDEX, ""));
let bm = yield PlacesUtils.bookmarks.insert({
parentGuid: (yield PlacesUtils.promiseItemGuid(folderIds[i])),
url: `http://Bookmark${i}_${j}.com`,
title: ""
});
bookmarkIds.push(yield PlacesUtils.promiseItemId(bm.guid));
}
}

View File

@ -649,12 +649,15 @@ tests.push({
LOG("Sorting test 8: SORT BY LASTMODIFIED");
var timeInMicroseconds = Date.now() * 1000;
var timeAddedInMicroseconds = timeInMicroseconds - 10000;
this._unsortedData = [
{ isBookmark: true,
uri: "http://example.com/b1",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
index: 0,
title: "y1",
dateAdded: timeAddedInMicroseconds,
lastModified: timeInMicroseconds - 1000,
isInQuery: true },
@ -663,6 +666,7 @@ tests.push({
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
index: 1,
title: "z",
dateAdded: timeAddedInMicroseconds,
lastModified: timeInMicroseconds - 2000,
isInQuery: true },
@ -671,6 +675,7 @@ tests.push({
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
index: 2,
title: "x",
dateAdded: timeAddedInMicroseconds,
lastModified: timeInMicroseconds,
isInQuery: true },
@ -680,6 +685,7 @@ tests.push({
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
index: 3,
title: "y2",
dateAdded: timeAddedInMicroseconds,
lastModified: timeInMicroseconds - 1000,
isInQuery: true },
@ -690,6 +696,7 @@ tests.push({
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
index: 4,
title: "y3",
dateAdded: timeAddedInMicroseconds,
lastModified: timeInMicroseconds - 1000,
isInQuery: true },
];

File diff suppressed because it is too large Load Diff

View File

@ -213,15 +213,18 @@ function* check_autocomplete(test) {
}
}
function addBookmark(aBookmarkObj) {
let addBookmark = Task.async(function* (aBookmarkObj) {
Assert.ok(!!aBookmarkObj.uri, "Bookmark object contains an uri");
let parentId = aBookmarkObj.parentId ? aBookmarkObj.parentId
: PlacesUtils.unfiledBookmarksFolderId;
let itemId = PlacesUtils.bookmarks
.insertBookmark(parentId,
aBookmarkObj.uri,
PlacesUtils.bookmarks.DEFAULT_INDEX,
aBookmarkObj.title || "A bookmark");
let bm = yield PlacesUtils.bookmarks.insert({
parentGuid: (yield PlacesUtils.promiseItemGuid(parentId)),
title: aBookmarkObj.title || "A bookmark",
url: aBookmarkObj.uri
});
let itemId = yield PlacesUtils.promiseItemId(bm.guid);
if (aBookmarkObj.keyword) {
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, aBookmarkObj.keyword);
}
@ -229,7 +232,7 @@ function addBookmark(aBookmarkObj) {
if (aBookmarkObj.tags) {
PlacesUtils.tagging.tagURI(aBookmarkObj.uri, aBookmarkObj.tags);
}
}
});
function addOpenPages(aUri, aCount=1) {
let ac = Cc["@mozilla.org/autocomplete/search;1?name=unifiedcomplete"]

View File

@ -11,9 +11,9 @@ add_task(function* test_tag_match_has_bookmark_title() {
do_print("Make sure the tag match gives the bookmark title");
let uri = NetUtil.newURI("http://theuri/");
yield PlacesTestUtils.addVisits({ uri: uri, title: "Page title" });
addBookmark({ uri: uri,
title: "Bookmark title",
tags: [ "superTag" ]});
yield addBookmark({ uri: uri,
title: "Bookmark title",
tags: [ "superTag" ]});
yield check_autocomplete({
search: "superTag",
matches: [ { uri: uri, title: "Bookmark title", tags: [ "superTag" ], style: [ "bookmark-tag" ] } ]

View File

@ -22,14 +22,14 @@ add_task(function* test_tag_match_url() {
{ uri: uri1, title: "title" },
{ uri: uri2, title: "title" }
]);
addBookmark({ uri: uri1,
title: "title",
tags: [ "superTag" ],
style: [ "bookmark-tag" ] });
addBookmark({ uri: uri2,
title: "title",
tags: [ "superTag" ],
style: [ "bookmark-tag" ] });
yield addBookmark({ uri: uri1,
title: "title",
tags: [ "superTag" ],
style: [ "bookmark-tag" ] });
yield addBookmark({ uri: uri2,
title: "title",
tags: [ "superTag" ],
style: [ "bookmark-tag" ] });
yield check_autocomplete({
search: "superTag",
matches: [ { uri: uri1, title: "title", tags: [ "superTag" ], style: [ "bookmark-tag" ] },

View File

@ -13,8 +13,8 @@ add_task(function* test_javascript_match() {
let uri1 = NetUtil.newURI("http://abc/def");
let uri2 = NetUtil.newURI("javascript:5");
yield PlacesTestUtils.addVisits([ { uri: uri1, title: "Title with javascript:" } ]);
addBookmark({ uri: uri2,
title: "Title with javascript:" });
yield addBookmark({ uri: uri2,
title: "Title with javascript:" });
do_print("Match non-javascript: with plain search");
yield check_autocomplete({

View File

@ -19,18 +19,18 @@ add_task(function* test_javascript_match() {
{ uri: uri3, title: "tagged" },
{ uri: uri4, title: "tagged" }
]);
addBookmark({ uri: uri1,
title: "tagged",
tags: [ "tag1" ] });
addBookmark({ uri: uri2,
title: "tagged",
tags: [ "tag1", "tag2" ] });
addBookmark({ uri: uri3,
title: "tagged",
tags: [ "tag1", "tag3" ] });
addBookmark({ uri: uri4,
title: "tagged",
tags: [ "tag1", "tag2", "tag3" ] });
yield addBookmark({ uri: uri1,
title: "tagged",
tags: [ "tag1" ] });
yield addBookmark({ uri: uri2,
title: "tagged",
tags: [ "tag1", "tag2" ] });
yield addBookmark({ uri: uri3,
title: "tagged",
tags: [ "tag1", "tag3" ] });
yield addBookmark({ uri: uri4,
title: "tagged",
tags: [ "tag1", "tag2", "tag3" ] });
do_print("Make sure tags come back in the title when matching tags");
yield check_autocomplete({

View File

@ -18,9 +18,9 @@ add_task(function* test_default_behavior_host() {
{ uri: uri2, title: "visited" },
{ uri: uri4, title: "tpbk", transition: TRANSITION_TYPED },
]);
addBookmark( { uri: uri3, title: "bookmarked" } );
addBookmark( { uri: uri4, title: "tpbk" } );
addBookmark( { uri: uri5, title: "title", tags: ["foo"] } );
yield addBookmark( { uri: uri3, title: "bookmarked" } );
yield addBookmark( { uri: uri4, title: "tpbk" } );
yield addBookmark( { uri: uri5, title: "title", tags: ["foo"] } );
// RESTRICT TO HISTORY.
Services.prefs.setBoolPref("browser.urlbar.suggest.history", true);
@ -200,8 +200,8 @@ add_task(function* test_default_behavior_url() {
{ uri: uri2, title: "visited" },
{ uri: uri4, title: "tpbk", transition: TRANSITION_TYPED },
]);
addBookmark( { uri: uri3, title: "bookmarked" } );
addBookmark( { uri: uri4, title: "tpbk" } );
yield addBookmark( { uri: uri3, title: "bookmarked" } );
yield addBookmark( { uri: uri4, title: "tpbk" } );
// RESTRICT TO HISTORY.
Services.prefs.setBoolPref("browser.urlbar.suggest.history", true);

View File

@ -74,7 +74,7 @@ add_task(function* test_respect_www() {
add_task(function* test_bookmark_first() {
do_print("With a bookmark and history, the query result should be the bookmark");
Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", false);
addBookmark({ uri: NetUtil.newURI("http://bookmark1.mozilla.org/") });
yield addBookmark({ uri: NetUtil.newURI("http://bookmark1.mozilla.org/") });
yield PlacesTestUtils.addVisits(NetUtil.newURI("http://bookmark1.mozilla.org/foo"));
yield check_autocomplete({
search: "bookmark",

View File

@ -24,12 +24,12 @@ add_task(function* test_download_embed_bookmarks() {
{ uri: uri5, title: "embed2", transition: TRANSITION_EMBED },
{ uri: uri6, title: "framed2", transition: TRANSITION_FRAMED_LINK }
]);
addBookmark({ uri: uri1,
title: "download-bookmark" });
addBookmark({ uri: uri2,
title: "embed-bookmark" });
addBookmark({ uri: uri3,
title: "framed-bookmark" });
yield addBookmark({ uri: uri1,
title: "download-bookmark" });
yield addBookmark({ uri: uri2,
title: "embed-bookmark" });
yield addBookmark({ uri: uri3,
title: "framed-bookmark" });
do_print("Searching for bookmarked download uri matches");
yield check_autocomplete({

View File

@ -25,14 +25,14 @@ add_task(function* test_javascript_match() {
{ uri: uri7, title: "title" }
]);
addBookmark({ uri: uri2,
title: "title" });
addBookmark({ uri: uri4,
title: "title" });
addBookmark({ uri: uri5,
title: "title" });
addBookmark({ uri: uri6,
title: "title" });
yield addBookmark({ uri: uri2,
title: "title" });
yield addBookmark({ uri: uri4,
title: "title" });
yield addBookmark({ uri: uri5,
title: "title" });
yield addBookmark({ uri: uri6,
title: "title" });
addOpenPages(uri7, 1);

View File

@ -19,7 +19,7 @@ add_task(function* test_keyword_searc() {
{ uri: uri1, title: "Generic page title" },
{ uri: uri2, title: "Generic page title" }
]);
addBookmark({ uri: uri1, title: "Keyword title", keyword: "key"});
yield addBookmark({ uri: uri1, title: "Keyword title", keyword: "key"});
do_print("Plain keyword query");
yield check_autocomplete({
@ -66,7 +66,7 @@ add_task(function* test_keyword_searc() {
// This adds a second keyword so anything after this will match 2 keywords
let uri3 = NetUtil.newURI("http://xyz/?foo=%s");
yield PlacesTestUtils.addVisits([ { uri: uri3, title: "Generic page title" } ]);
addBookmark({ uri: uri3, title: "Keyword title", keyword: "key", style: ["keyword"] });
yield addBookmark({ uri: uri3, title: "Keyword title", keyword: "key", style: ["keyword"] });
do_print("Two keywords matched");
yield check_autocomplete({

View File

@ -19,7 +19,7 @@ add_task(function* test_keyword_search() {
{ uri: uri1, title: "Generic page title" },
{ uri: uri2, title: "Generic page title" }
]);
addBookmark({ uri: uri1, title: "Keyword title", keyword: "key"});
yield addBookmark({ uri: uri1, title: "Keyword title", keyword: "key"});
do_print("Plain keyword query");
yield check_autocomplete({
@ -73,7 +73,7 @@ add_task(function* test_keyword_search() {
// This adds a second keyword so anything after this will match 2 keywords
let uri3 = NetUtil.newURI("http://xyz/?foo=%s");
yield PlacesTestUtils.addVisits([ { uri: uri3, title: "Generic page title" } ]);
addBookmark({ uri: uri3, title: "Keyword title", keyword: "key"});
yield addBookmark({ uri: uri3, title: "Keyword title", keyword: "key"});
do_print("Two keywords matched");
yield check_autocomplete({

View File

@ -8,7 +8,7 @@ add_task(function* test_non_keyword() {
uri: NetUtil.newURI("http://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
addBookmark({ uri: NetUtil.newURI("http://mozilla.org/test/") });
yield addBookmark({ uri: NetUtil.newURI("http://mozilla.org/test/") });
yield check_autocomplete({
search: "moz",
autofilled: "mozilla.org/",
@ -23,7 +23,7 @@ add_task(function* test_keyword() {
uri: NetUtil.newURI("http://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
addBookmark({ uri: NetUtil.newURI("http://mozilla.org/test/"), keyword: "moz" });
yield addBookmark({ uri: NetUtil.newURI("http://mozilla.org/test/"), keyword: "moz" });
yield check_autocomplete({
search: "moz",
autofilled: "moz",
@ -38,7 +38,7 @@ add_task(function* test_more_than_keyword() {
uri: NetUtil.newURI("http://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
addBookmark({ uri: NetUtil.newURI("http://mozilla.org/test/"), keyword: "moz" });
yield addBookmark({ uri: NetUtil.newURI("http://mozilla.org/test/"), keyword: "moz" });
yield check_autocomplete({
search: "mozi",
autofilled: "mozilla.org/",
@ -53,7 +53,7 @@ add_task(function* test_less_than_keyword() {
uri: NetUtil.newURI("http://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
addBookmark({ uri: NetUtil.newURI("http://mozilla.org/test/"), keyword: "moz" });
yield addBookmark({ uri: NetUtil.newURI("http://mozilla.org/test/"), keyword: "moz" });
yield check_autocomplete({
search: "mo",
autofilled: "mozilla.org/",
@ -68,7 +68,7 @@ add_task(function* test_keyword_casing() {
uri: NetUtil.newURI("http://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
addBookmark({ uri: NetUtil.newURI("http://mozilla.org/test/"), keyword: "moz" });
yield addBookmark({ uri: NetUtil.newURI("http://mozilla.org/test/"), keyword: "moz" });
yield check_autocomplete({
search: "MoZ",
autofilled: "MoZ",

View File

@ -23,8 +23,8 @@ add_task(function* test_match_beginning() {
{ uri: uri3, title: "f(o)o b<a>r" },
{ uri: uri4, title: "f(o)o b<a>r" }
]);
addBookmark({ uri: uri3, title: "f(o)o b<a>r" });
addBookmark({ uri: uri4, title: "b(a)r b<a>z" });
yield addBookmark({ uri: uri3, title: "f(o)o b<a>r" });
yield addBookmark({ uri: uri4, title: "b(a)r b<a>z" });
do_print("Match 2 terms all in url");
yield check_autocomplete({

View File

@ -51,7 +51,7 @@ add_task(function* test_searchEngine_autoFill() {
visits.push({ uri , title: "Terms - SearchEngine Search" });
}
yield PlacesTestUtils.addVisits(visits);
addBookmark({ uri: uri, title: "Example bookmark" });
yield addBookmark({ uri: uri, title: "Example bookmark" });
yield PlacesTestUtils.promiseAsyncUpdates();
ok(frecencyForUrl(uri) > 10000, "Added URI should have expected high frecency");

View File

@ -12,7 +12,7 @@ add_task(function* test_searchEngine() {
let uri1 = NetUtil.newURI("http://s.example.com/search?q=Terms&client=1");
let uri2 = NetUtil.newURI("http://s.example.com/search?q=Terms&client=2");
yield PlacesTestUtils.addVisits({ uri: uri1, title: "Terms - SearchEngine Search" });
addBookmark({ uri: uri2, title: "Terms - SearchEngine Search" });
yield addBookmark({ uri: uri2, title: "Terms - SearchEngine Search" });
do_print("Past search terms should be styled, unless bookmarked");
Services.prefs.setBoolPref("browser.urlbar.restyleSearches", true);

View File

@ -37,14 +37,14 @@ add_task(function* test_special_searches() {
{ uri: uri6, title: "foo.bar" },
{ uri: uri11, title: "title", transition: TRANSITION_TYPED }
]);
addBookmark( { uri: uri5, title: "title" } );
addBookmark( { uri: uri6, title: "foo.bar" } );
addBookmark( { uri: uri7, title: "title" } );
addBookmark( { uri: uri8, title: "foo.bar" } );
addBookmark( { uri: uri9, title: "title", tags: [ "foo.bar" ] } );
addBookmark( { uri: uri10, title: "foo.bar", tags: [ "foo.bar" ] } );
addBookmark( { uri: uri11, title: "title", tags: [ "foo.bar" ] } );
addBookmark( { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ] } );
yield addBookmark( { uri: uri5, title: "title" } );
yield addBookmark( { uri: uri6, title: "foo.bar" } );
yield addBookmark( { uri: uri7, title: "title" } );
yield addBookmark( { uri: uri8, title: "foo.bar" } );
yield addBookmark( { uri: uri9, title: "title", tags: [ "foo.bar" ] } );
yield addBookmark( { uri: uri10, title: "foo.bar", tags: [ "foo.bar" ] } );
yield addBookmark( { uri: uri11, title: "title", tags: [ "foo.bar" ] } );
yield addBookmark( { uri: uri12, title: "foo.bar", tags: [ "foo.bar" ] } );
// Test restricting searches
do_print("History restrict");

View File

@ -43,8 +43,8 @@ add_task(function* test_escape() {
{ uri: uri9, title: ideograph.join("") },
{ uri: uri10, title: "title1" }
]);
addBookmark( { uri: uri5, title: "title1", tags: [ "matchme2" ] } );
addBookmark( { uri: uri6, title: "title1", tags: [ "dontmatchme3" ] } );
yield addBookmark( { uri: uri5, title: "title1", tags: [ "matchme2" ] } );
yield addBookmark( { uri: uri6, title: "title1", tags: [ "dontmatchme3" ] } );
// match only on word boundaries
Services.prefs.setIntPref("browser.urlbar.matchBehavior", 2);