merge fx-team to mozilla-central a=merge IGNORE IDL

--HG--
extra : amend_source : 9f98aec21c9b160ff3890cdc3802e4fe4d0583f0
This commit is contained in:
Carsten "Tomcat" Book 2015-04-22 15:15:48 +02:00
Родитель 58699c38f6 65beaee4c9
Коммит dae71fdffa
42 изменённых файлов: 953 добавлений и 365 удалений

Просмотреть файл

@ -707,6 +707,19 @@ function injectLoopAPI(targetWindow) {
},
},
/**
* Opens a URL in a new tab in the browser.
*
* @param {String} url The new url to open
*/
openURL: {
enumerable: true,
writable: true,
value: function(url) {
return MozLoopService.openURL(url);
}
},
/**
* Copies passed string onto the system clipboard.
*

Просмотреть файл

@ -1650,6 +1650,16 @@ this.MozLoopService = {
}
}),
/**
* Opens a URL in a new tab in the browser.
*
* @param {String} url The new url to open
*/
openURL: function(url) {
let win = Services.wm.getMostRecentWindow("navigator:browser");
win.openUILinkIn(url, "tab");
},
/**
* Performs a hawk based request to the loop server.
*

Просмотреть файл

@ -260,6 +260,8 @@ body[dir=rtl] .new-room-view > .context > .context-preview {
display: inline-block;
font-size: .85rem;
color: #777;
/* See .room-entry-context-item for the margin/size reductions. */
width: calc(100% - 1rem - 16px);
}
.room-list > .room-entry.room-active > h2 {
@ -354,6 +356,19 @@ body[dir=rtl] .new-room-view > .context > .context-preview {
vertical-align: middle;
}
/* Keep ".room-list > .room-entry > h2" in sync with these. */
.room-entry-context-item {
display: inline-block;
vertical-align: middle;
margin-left: 1rem;
height: 16px;
}
.room-entry-context-item > a > img {
height: 16px;
width: 16px;
}
/* Buttons */
.button-group {

Просмотреть файл

@ -11,6 +11,8 @@ var loop = loop || {};
loop.contacts = (function(_, mozL10n) {
"use strict";
var sharedMixins = loop.shared.mixins;
const Button = loop.shared.views.Button;
const ButtonGroup = loop.shared.views.ButtonGroup;
const CALL_TYPES = loop.shared.utils.CALL_TYPES;
@ -82,6 +84,8 @@ loop.contacts = (function(_, mozL10n) {
};
const GravatarPromo = React.createClass({displayName: "GravatarPromo",
mixins: [sharedMixins.WindowCloseMixin],
propTypes: {
handleUse: React.PropTypes.func.isRequired
},
@ -98,6 +102,16 @@ loop.contacts = (function(_, mozL10n) {
this.setState({ showMe: false });
},
handleLinkClick: function(event) {
if (!event.target || !event.target.href) {
return;
}
event.preventDefault();
navigator.mozLoop.openURL(event.target.href);
this.closeWindow();
},
handleUseButtonClick: function() {
navigator.mozLoop.setLoopPref("contacts.gravatars.promo", false);
navigator.mozLoop.setLoopPref("contacts.gravatars.show", true);
@ -121,7 +135,8 @@ loop.contacts = (function(_, mozL10n) {
return (
React.createElement("div", {className: "contacts-gravatar-promo"},
React.createElement(Button, {additionalClass: "button-close", onClick: this.handleCloseButtonClick}),
React.createElement("p", {dangerouslySetInnerHTML: {__html: message}}),
React.createElement("p", {dangerouslySetInnerHTML: {__html: message},
onClick: this.handleLinkClick}),
React.createElement(ButtonGroup, null,
React.createElement(Button, {caption: mozL10n.get("gravatars_promo_button_nothanks"),
onClick: this.handleCloseButtonClick}),

Просмотреть файл

@ -11,6 +11,8 @@ var loop = loop || {};
loop.contacts = (function(_, mozL10n) {
"use strict";
var sharedMixins = loop.shared.mixins;
const Button = loop.shared.views.Button;
const ButtonGroup = loop.shared.views.ButtonGroup;
const CALL_TYPES = loop.shared.utils.CALL_TYPES;
@ -82,6 +84,8 @@ loop.contacts = (function(_, mozL10n) {
};
const GravatarPromo = React.createClass({
mixins: [sharedMixins.WindowCloseMixin],
propTypes: {
handleUse: React.PropTypes.func.isRequired
},
@ -98,6 +102,16 @@ loop.contacts = (function(_, mozL10n) {
this.setState({ showMe: false });
},
handleLinkClick: function(event) {
if (!event.target || !event.target.href) {
return;
}
event.preventDefault();
navigator.mozLoop.openURL(event.target.href);
this.closeWindow();
},
handleUseButtonClick: function() {
navigator.mozLoop.setLoopPref("contacts.gravatars.promo", false);
navigator.mozLoop.setLoopPref("contacts.gravatars.show", true);
@ -121,7 +135,8 @@ loop.contacts = (function(_, mozL10n) {
return (
<div className="contacts-gravatar-promo">
<Button additionalClass="button-close" onClick={this.handleCloseButtonClick}/>
<p dangerouslySetInnerHTML={{__html: message}}></p>
<p dangerouslySetInnerHTML={{__html: message}}
onClick={this.handleLinkClick}></p>
<ButtonGroup>
<Button caption={mozL10n.get("gravatars_promo_button_nothanks")}
onClick={this.handleCloseButtonClick}/>

Просмотреть файл

@ -215,6 +215,8 @@ loop.panel = (function(_, mozL10n) {
});
var ToSView = React.createClass({displayName: "ToSView",
mixins: [sharedMixins.WindowCloseMixin],
getInitialState: function() {
var getPref = navigator.mozLoop.getLoopPref.bind(navigator.mozLoop);
@ -225,6 +227,16 @@ loop.panel = (function(_, mozL10n) {
};
},
handleLinkClick: function(event) {
if (!event.target || !event.target.href) {
return;
}
event.preventDefault();
navigator.mozLoop.openURL(event.target.href);
this.closeWindow();
},
renderPartnerLogo: function() {
if (!this.state.showPartnerLogo) {
return null;
@ -262,7 +274,8 @@ loop.panel = (function(_, mozL10n) {
React.createElement("div", {id: "powered-by-wrapper"},
this.renderPartnerLogo(),
React.createElement("p", {className: "terms-service",
dangerouslySetInnerHTML: {__html: tosHTML}})
dangerouslySetInnerHTML: {__html: tosHTML},
onClick: this.handleLinkClick})
)
);
} else {
@ -305,6 +318,10 @@ loop.panel = (function(_, mozL10n) {
* Panel settings (gear) menu.
*/
var SettingsDropdown = React.createClass({displayName: "SettingsDropdown",
propTypes: {
mozLoop: React.PropTypes.object.isRequired
},
mixins: [sharedMixins.DropdownMenuMixin, sharedMixins.WindowCloseMixin],
handleClickSettingsEntry: function() {
@ -312,30 +329,31 @@ loop.panel = (function(_, mozL10n) {
},
handleClickAccountEntry: function() {
navigator.mozLoop.openFxASettings();
this.props.mozLoop.openFxASettings();
this.closeWindow();
},
handleClickAuthEntry: function() {
if (this._isSignedIn()) {
navigator.mozLoop.logOutFromFxA();
this.props.mozLoop.logOutFromFxA();
} else {
navigator.mozLoop.logInToFxA();
this.props.mozLoop.logInToFxA();
}
},
handleHelpEntry: function(event) {
event.preventDefault();
var helloSupportUrl = navigator.mozLoop.getLoopPref('support_url');
window.open(helloSupportUrl);
window.close();
var helloSupportUrl = this.props.mozLoop.getLoopPref("support_url");
this.props.mozLoop.openURL(helloSupportUrl);
this.closeWindow();
},
_isSignedIn: function() {
return !!navigator.mozLoop.userProfile;
return !!this.props.mozLoop.userProfile;
},
openGettingStartedTour: function() {
navigator.mozLoop.openGettingStartedTour("settings-menu");
this.props.mozLoop.openGettingStartedTour("settings-menu");
this.closeWindow();
},
@ -356,7 +374,7 @@ loop.panel = (function(_, mozL10n) {
React.createElement(SettingsDropdownEntry, {label: mozL10n.get("settings_menu_item_account"),
onClick: this.handleClickAccountEntry,
icon: "account",
displayed: this._isSignedIn() && navigator.mozLoop.fxAEnabled}),
displayed: this._isSignedIn() && this.props.mozLoop.fxAEnabled}),
React.createElement(SettingsDropdownEntry, {icon: "tour",
label: mozL10n.get("tour_label"),
onClick: this.openGettingStartedTour}),
@ -364,7 +382,7 @@ loop.panel = (function(_, mozL10n) {
mozL10n.get("settings_menu_item_signout") :
mozL10n.get("settings_menu_item_signin"),
onClick: this.handleClickAuthEntry,
displayed: navigator.mozLoop.fxAEnabled,
displayed: this.props.mozLoop.fxAEnabled,
icon: this._isSignedIn() ? "signout" : "signin"}),
React.createElement(SettingsDropdownEntry, {label: mozL10n.get("help_label"),
onClick: this.handleHelpEntry,
@ -413,13 +431,43 @@ loop.panel = (function(_, mozL10n) {
}
});
var RoomEntryContextItem = React.createClass({displayName: "RoomEntryContextItem",
propTypes: {
mozLoop: React.PropTypes.object.isRequired,
roomUrls: React.PropTypes.object
},
handleClick: function(event) {
event.stopPropagation();
event.preventDefault();
this.props.mozLoop.openURL(event.currentTarget.href);
},
render: function() {
var roomUrl = this.props.roomUrls && this.props.roomUrls[0];
if (!roomUrl) {
return null;
}
return (
React.createElement("div", {className: "room-entry-context-item"},
React.createElement("a", {href: roomUrl.location, onClick: this.handleClick},
React.createElement("img", {title: roomUrl.description,
src: roomUrl.thumbnail})
)
)
);
}
});
/**
* Room list entry.
*/
var RoomEntry = React.createClass({displayName: "RoomEntry",
propTypes: {
dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
room: React.PropTypes.instanceOf(loop.store.Room).isRequired
mozLoop: React.PropTypes.object.isRequired,
room: React.PropTypes.instanceOf(loop.store.Room).isRequired
},
mixins: [loop.shared.mixins.WindowCloseMixin],
@ -453,7 +501,7 @@ loop.panel = (function(_, mozL10n) {
handleDeleteButtonClick: function(event) {
event.stopPropagation();
event.preventDefault();
navigator.mozLoop.confirm({
this.props.mozLoop.confirm({
message: mozL10n.get("rooms_list_deleteConfirmation_label"),
okButton: null,
cancelButton: null
@ -502,7 +550,9 @@ loop.panel = (function(_, mozL10n) {
React.createElement("button", {className: "delete-link",
title: mozL10n.get("rooms_list_delete_tooltip"),
onClick: this.handleDeleteButtonClick})
)
),
React.createElement(RoomEntryContextItem, {mozLoop: this.props.mozLoop,
roomUrls: this.props.room.decryptedContext.urls})
)
);
}
@ -574,6 +624,7 @@ loop.panel = (function(_, mozL10n) {
React.createElement(RoomEntry, {
key: room.roomToken,
dispatcher: this.props.dispatcher,
mozLoop: this.props.mozLoop,
room: room}
)
);
@ -689,7 +740,7 @@ loop.panel = (function(_, mozL10n) {
showTabButtons: React.PropTypes.bool,
selectedTab: React.PropTypes.string,
dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
mozLoop: React.PropTypes.object,
mozLoop: React.PropTypes.object.isRequired,
roomStore:
React.PropTypes.instanceOf(loop.store.RoomStore).isRequired
},
@ -848,7 +899,7 @@ loop.panel = (function(_, mozL10n) {
React.createElement("div", {className: "signin-details"},
React.createElement(AuthLink, null),
React.createElement("div", {className: "footer-signin-separator"}),
React.createElement(SettingsDropdown, null)
React.createElement(SettingsDropdown, {mozLoop: this.props.mozLoop})
)
)
)

Просмотреть файл

@ -215,6 +215,8 @@ loop.panel = (function(_, mozL10n) {
});
var ToSView = React.createClass({
mixins: [sharedMixins.WindowCloseMixin],
getInitialState: function() {
var getPref = navigator.mozLoop.getLoopPref.bind(navigator.mozLoop);
@ -225,6 +227,16 @@ loop.panel = (function(_, mozL10n) {
};
},
handleLinkClick: function(event) {
if (!event.target || !event.target.href) {
return;
}
event.preventDefault();
navigator.mozLoop.openURL(event.target.href);
this.closeWindow();
},
renderPartnerLogo: function() {
if (!this.state.showPartnerLogo) {
return null;
@ -262,7 +274,8 @@ loop.panel = (function(_, mozL10n) {
<div id="powered-by-wrapper">
{this.renderPartnerLogo()}
<p className="terms-service"
dangerouslySetInnerHTML={{__html: tosHTML}}></p>
dangerouslySetInnerHTML={{__html: tosHTML}}
onClick={this.handleLinkClick}></p>
</div>
);
} else {
@ -305,6 +318,10 @@ loop.panel = (function(_, mozL10n) {
* Panel settings (gear) menu.
*/
var SettingsDropdown = React.createClass({
propTypes: {
mozLoop: React.PropTypes.object.isRequired
},
mixins: [sharedMixins.DropdownMenuMixin, sharedMixins.WindowCloseMixin],
handleClickSettingsEntry: function() {
@ -312,30 +329,31 @@ loop.panel = (function(_, mozL10n) {
},
handleClickAccountEntry: function() {
navigator.mozLoop.openFxASettings();
this.props.mozLoop.openFxASettings();
this.closeWindow();
},
handleClickAuthEntry: function() {
if (this._isSignedIn()) {
navigator.mozLoop.logOutFromFxA();
this.props.mozLoop.logOutFromFxA();
} else {
navigator.mozLoop.logInToFxA();
this.props.mozLoop.logInToFxA();
}
},
handleHelpEntry: function(event) {
event.preventDefault();
var helloSupportUrl = navigator.mozLoop.getLoopPref('support_url');
window.open(helloSupportUrl);
window.close();
var helloSupportUrl = this.props.mozLoop.getLoopPref("support_url");
this.props.mozLoop.openURL(helloSupportUrl);
this.closeWindow();
},
_isSignedIn: function() {
return !!navigator.mozLoop.userProfile;
return !!this.props.mozLoop.userProfile;
},
openGettingStartedTour: function() {
navigator.mozLoop.openGettingStartedTour("settings-menu");
this.props.mozLoop.openGettingStartedTour("settings-menu");
this.closeWindow();
},
@ -356,7 +374,7 @@ loop.panel = (function(_, mozL10n) {
<SettingsDropdownEntry label={mozL10n.get("settings_menu_item_account")}
onClick={this.handleClickAccountEntry}
icon="account"
displayed={this._isSignedIn() && navigator.mozLoop.fxAEnabled} />
displayed={this._isSignedIn() && this.props.mozLoop.fxAEnabled} />
<SettingsDropdownEntry icon="tour"
label={mozL10n.get("tour_label")}
onClick={this.openGettingStartedTour} />
@ -364,7 +382,7 @@ loop.panel = (function(_, mozL10n) {
mozL10n.get("settings_menu_item_signout") :
mozL10n.get("settings_menu_item_signin")}
onClick={this.handleClickAuthEntry}
displayed={navigator.mozLoop.fxAEnabled}
displayed={this.props.mozLoop.fxAEnabled}
icon={this._isSignedIn() ? "signout" : "signin"} />
<SettingsDropdownEntry label={mozL10n.get("help_label")}
onClick={this.handleHelpEntry}
@ -413,13 +431,43 @@ loop.panel = (function(_, mozL10n) {
}
});
var RoomEntryContextItem = React.createClass({
propTypes: {
mozLoop: React.PropTypes.object.isRequired,
roomUrls: React.PropTypes.object
},
handleClick: function(event) {
event.stopPropagation();
event.preventDefault();
this.props.mozLoop.openURL(event.currentTarget.href);
},
render: function() {
var roomUrl = this.props.roomUrls && this.props.roomUrls[0];
if (!roomUrl) {
return null;
}
return (
<div className="room-entry-context-item">
<a href={roomUrl.location} onClick={this.handleClick}>
<img title={roomUrl.description}
src={roomUrl.thumbnail} />
</a>
</div>
);
}
});
/**
* Room list entry.
*/
var RoomEntry = React.createClass({
propTypes: {
dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
room: React.PropTypes.instanceOf(loop.store.Room).isRequired
mozLoop: React.PropTypes.object.isRequired,
room: React.PropTypes.instanceOf(loop.store.Room).isRequired
},
mixins: [loop.shared.mixins.WindowCloseMixin],
@ -453,7 +501,7 @@ loop.panel = (function(_, mozL10n) {
handleDeleteButtonClick: function(event) {
event.stopPropagation();
event.preventDefault();
navigator.mozLoop.confirm({
this.props.mozLoop.confirm({
message: mozL10n.get("rooms_list_deleteConfirmation_label"),
okButton: null,
cancelButton: null
@ -503,6 +551,8 @@ loop.panel = (function(_, mozL10n) {
title={mozL10n.get("rooms_list_delete_tooltip")}
onClick={this.handleDeleteButtonClick} />
</h2>
<RoomEntryContextItem mozLoop={this.props.mozLoop}
roomUrls={this.props.room.decryptedContext.urls} />
</div>
);
}
@ -574,6 +624,7 @@ loop.panel = (function(_, mozL10n) {
<RoomEntry
key={room.roomToken}
dispatcher={this.props.dispatcher}
mozLoop={this.props.mozLoop}
room={room}
/>
);
@ -689,7 +740,7 @@ loop.panel = (function(_, mozL10n) {
showTabButtons: React.PropTypes.bool,
selectedTab: React.PropTypes.string,
dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
mozLoop: React.PropTypes.object,
mozLoop: React.PropTypes.object.isRequired,
roomStore:
React.PropTypes.instanceOf(loop.store.RoomStore).isRequired
},
@ -848,7 +899,7 @@ loop.panel = (function(_, mozL10n) {
<div className="signin-details">
<AuthLink />
<div className="footer-signin-separator" />
<SettingsDropdown />
<SettingsDropdown mozLoop={this.props.mozLoop}/>
</div>
</div>
</div>

Просмотреть файл

@ -71,6 +71,7 @@ describe("loop.panel", function() {
},
confirm: sandbox.stub(),
notifyUITour: sandbox.stub(),
openURL: sandbox.stub(),
getSelectedTabMetadata: sandbox.stub()
};
@ -188,6 +189,19 @@ describe("loop.panel", function() {
}));
}
it("should hide the account entry when FxA is not enabled", function() {
navigator.mozLoop.userProfile = {email: "test@example.com"};
navigator.mozLoop.fxAEnabled = false;
var view = TestUtils.renderIntoDocument(
React.createElement(loop.panel.SettingsDropdown, {
mozLoop: fakeMozLoop
}));
expect(view.getDOMNode().querySelectorAll(".icon-account"))
.to.have.length.of(0);
});
describe('TabView', function() {
var view, callTab, roomsTab, contactsTab;
@ -268,18 +282,14 @@ describe("loop.panel", function() {
});
});
it("should hide the account entry when FxA is not enabled", function() {
navigator.mozLoop.userProfile = {email: "test@example.com"};
navigator.mozLoop.fxAEnabled = false;
var view = TestUtils.renderIntoDocument(
React.createElement(loop.panel.SettingsDropdown));
expect(view.getDOMNode().querySelectorAll(".icon-account"))
.to.have.length.of(0);
});
describe("SettingsDropdown", function() {
function mountTestComponent() {
return TestUtils.renderIntoDocument(
React.createElement(loop.panel.SettingsDropdown, {
mozLoop: fakeMozLoop
}));
}
beforeEach(function() {
navigator.mozLoop.logInToFxA = sandbox.stub();
navigator.mozLoop.logOutFromFxA = sandbox.stub();
@ -294,8 +304,7 @@ describe("loop.panel", function() {
function() {
navigator.mozLoop.loggedInToFxA = false;
var view = TestUtils.renderIntoDocument(
React.createElement(loop.panel.SettingsDropdown));
var view = mountTestComponent();
expect(view.getDOMNode().querySelectorAll(".icon-signout"))
.to.have.length.of(0);
@ -306,8 +315,7 @@ describe("loop.panel", function() {
it("should show a signout entry when user is authenticated", function() {
navigator.mozLoop.userProfile = {email: "test@example.com"};
var view = TestUtils.renderIntoDocument(
React.createElement(loop.panel.SettingsDropdown));
var view = mountTestComponent();
expect(view.getDOMNode().querySelectorAll(".icon-signout"))
.to.have.length.of(1);
@ -318,8 +326,7 @@ describe("loop.panel", function() {
it("should show an account entry when user is authenticated", function() {
navigator.mozLoop.userProfile = {email: "test@example.com"};
var view = TestUtils.renderIntoDocument(
React.createElement(loop.panel.SettingsDropdown));
var view = mountTestComponent();
expect(view.getDOMNode().querySelectorAll(".icon-account"))
.to.have.length.of(1);
@ -328,8 +335,7 @@ describe("loop.panel", function() {
it("should open the FxA settings when the account entry is clicked", function() {
navigator.mozLoop.userProfile = {email: "test@example.com"};
var view = TestUtils.renderIntoDocument(
React.createElement(loop.panel.SettingsDropdown));
var view = mountTestComponent();
TestUtils.Simulate.click(
view.getDOMNode().querySelector(".icon-account"));
@ -341,8 +347,7 @@ describe("loop.panel", function() {
function() {
navigator.mozLoop.loggedInToFxA = false;
var view = TestUtils.renderIntoDocument(
React.createElement(loop.panel.SettingsDropdown));
var view = mountTestComponent();
expect(view.getDOMNode().querySelectorAll(".icon-account"))
.to.have.length.of(0);
@ -350,8 +355,7 @@ describe("loop.panel", function() {
it("should sign in the user on click when unauthenticated", function() {
navigator.mozLoop.loggedInToFxA = false;
var view = TestUtils.renderIntoDocument(
React.createElement(loop.panel.SettingsDropdown));
var view = mountTestComponent();
TestUtils.Simulate.click(
view.getDOMNode().querySelector(".icon-signin"));
@ -361,8 +365,7 @@ describe("loop.panel", function() {
it("should sign out the user on click when authenticated", function() {
navigator.mozLoop.userProfile = {email: "test@example.com"};
var view = TestUtils.renderIntoDocument(
React.createElement(loop.panel.SettingsDropdown));
var view = mountTestComponent();
TestUtils.Simulate.click(
view.getDOMNode().querySelector(".icon-signout"));
@ -372,28 +375,41 @@ describe("loop.panel", function() {
});
describe("Help", function() {
var supportUrl = "https://example.com";
var view, supportUrl;
function mountTestComponent() {
return TestUtils.renderIntoDocument(
React.createElement(loop.panel.SettingsDropdown, {
mozLoop: fakeMozLoop
}));
}
beforeEach(function() {
supportUrl = "https://example.com";
navigator.mozLoop.getLoopPref = function(pref) {
if (pref === "support_url")
return supportUrl;
return "unseen";
};
sandbox.stub(window, "open");
sandbox.stub(window, "close");
});
it("should open a tab to the support page", function() {
var view = TestUtils.renderIntoDocument(
React.createElement(loop.panel.SettingsDropdown));
view = mountTestComponent();
TestUtils.Simulate
.click(view.getDOMNode().querySelector(".icon-help"));
sinon.assert.calledOnce(window.open);
sinon.assert.calledWithExactly(window.open, supportUrl);
sinon.assert.calledOnce(fakeMozLoop.openURL);
sinon.assert.calledWithExactly(fakeMozLoop.openURL, supportUrl);
});
it("should close the panel", function() {
view = mountTestComponent();
TestUtils.Simulate
.click(view.getDOMNode().querySelector(".icon-help"));
sinon.assert.calledOnce(fakeWindow.close);
});
});
@ -463,6 +479,10 @@ describe("loop.panel", function() {
});
function mountRoomEntry(props) {
props = _.extend({
dispatcher: dispatcher,
mozLoop: fakeMozLoop
}, props);
return TestUtils.renderIntoDocument(
React.createElement(loop.panel.RoomEntry, props));
}
@ -472,7 +492,6 @@ describe("loop.panel", function() {
beforeEach(function() {
roomEntry = mountRoomEntry({
dispatcher: dispatcher,
deleteRoom: sandbox.stub(),
room: new loop.store.Room(roomData)
});
@ -522,7 +541,6 @@ describe("loop.panel", function() {
beforeEach(function() {
roomEntry = mountRoomEntry({
dispatcher: dispatcher,
room: new loop.store.Room(roomData)
});
deleteButton = roomEntry.getDOMNode().querySelector("button.delete-link");
@ -555,6 +573,49 @@ describe("loop.panel", function() {
});
});
describe("Context Indicator", function() {
var roomEntry;
function mountEntryForContext() {
return mountRoomEntry({
room: new loop.store.Room(roomData)
});
}
it("should not display a context indicator if the room doesn't have any", function() {
roomEntry = mountEntryForContext();
expect(roomEntry.getDOMNode().querySelector(".room-entry-context-item")).eql(null);
});
it("should a context indicator if the room specifies context", function() {
roomData.decryptedContext.urls = [{
description: "invalid entry",
location: "http://invalid",
thumbnail: "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
}];
roomEntry = mountEntryForContext();
expect(roomEntry.getDOMNode().querySelector(".room-entry-context-item")).not.eql(null);
});
it("should call mozLoop.openURL to open a new url", function() {
roomData.decryptedContext.urls = [{
description: "invalid entry",
location: "http://invalid/",
thumbnail: "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
}];
roomEntry = mountEntryForContext();
TestUtils.Simulate.click(roomEntry.getDOMNode().querySelector("a"));
sinon.assert.calledOnce(fakeMozLoop.openURL);
sinon.assert.calledWithExactly(fakeMozLoop.openURL, "http://invalid/");
});
});
describe("Room Entry click", function() {
var roomEntry, roomEntryNode;

Просмотреть файл

@ -7,7 +7,12 @@ var fakeRooms = [
{
"roomToken": "_nxD4V4FflQ",
"decryptedContext": {
"roomName": "First Room Name"
"roomName": "First Room Name",
"urls": [{
description: "The mozilla page",
location: "https://www.mozilla.org",
thumbnail: "https://www.mozilla.org/favicon.ico"
}]
},
"roomUrl": "http://localhost:3000/rooms/_nxD4V4FflQ",
"roomOwner": "Alexis",

Просмотреть файл

@ -7,6 +7,7 @@
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
const policy = Cc["@mozilla.org/datareporting/service;1"]
.getService(Ci.nsISupports)
@ -63,6 +64,10 @@ MozSelfSupportInterface.prototype = {
}
}.bind(this));
},
resetPref: function(name) {
Services.prefs.clearUserPref(name);
},
}
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MozSelfSupportInterface]);

Просмотреть файл

@ -8,3 +8,7 @@ EXTRA_COMPONENTS += [
'SelfSupportService.js',
'SelfSupportService.manifest',
]
BROWSER_CHROME_MANIFESTS += [
'test/browser.ini',
]

Просмотреть файл

@ -0,0 +1,3 @@
[DEFAULT]
[browser_selfsupportAPI.js]

Просмотреть файл

@ -0,0 +1,47 @@
Cu.import("resource://gre/modules/Preferences.jsm");
function test() {
const prefNewName = "browser.newpref.fake";
Assert.ok(!Preferences.has(prefNewName), "pref should not exist");
const prefExistingName = "extensions.hotfix.id";
Assert.ok(Preferences.has(prefExistingName), "pref should exist");
Assert.ok(!Preferences.isSet(prefExistingName), "pref should not be user-set");
let prefExistingOriginalValue = Preferences.get(prefExistingName);
registerCleanupFunction(function() {
Preferences.set(prefExistingName, prefExistingOriginalValue);
Services.prefs.deleteBranch(prefNewName);
});
// 1. do nothing on an inexistent pref
MozSelfSupport.resetPref(prefNewName);
Assert.ok(!Preferences.has(prefNewName), "pref should still not exist");
// 2. creation of a new pref
Preferences.set(prefNewName, 10);
Assert.ok(Preferences.has(prefNewName), "pref should exist");
Assert.equal(Preferences.get(prefNewName), 10, "pref value should be 10");
MozSelfSupport.resetPref(prefNewName);
Assert.ok(!Preferences.has(prefNewName), "pref should not exist any more");
// 3. do nothing on an unchanged existing pref
MozSelfSupport.resetPref(prefExistingName);
Assert.ok(Preferences.has(prefExistingName), "pref should still exist");
Assert.equal(Preferences.get(prefExistingName), prefExistingOriginalValue, "pref value should be the same as original");
// 4. change the value of an existing pref
Preferences.set(prefExistingName, "anyone@mozilla.org");
Assert.ok(Preferences.has(prefExistingName), "pref should exist");
Assert.equal(Preferences.get(prefExistingName), "anyone@mozilla.org", "pref value should have changed");
MozSelfSupport.resetPref(prefExistingName);
Assert.ok(Preferences.has(prefExistingName), "pref should still exist");
Assert.equal(Preferences.get(prefExistingName), prefExistingOriginalValue, "pref value should be the same as original");
// 5. delete an existing pref
// deleteBranch is implemented in such a way that
// clearUserPref can't undo its action
// see discussion in bug 1075160
}

Просмотреть файл

@ -2162,7 +2162,7 @@ MarkupElementContainer.prototype = Heritage.extend(MarkupContainer.prototype, {
*/
isImagePreviewTarget: function(target, tooltip) {
if (!this.tooltipData || this.tooltipData.target !== target) {
return promise.reject();
return promise.reject(false);
}
return this.tooltipData.data.then(({data, size}) => {

Просмотреть файл

@ -453,8 +453,6 @@ Tooltip.prototype = {
if (res && res.then) {
return res.then(arg => {
return arg instanceof Ci.nsIDOMNode ? arg : target;
}, () => {
return false;
});
} else {
let newTarget = res instanceof Ci.nsIDOMNode ? res : target;

Просмотреть файл

@ -220,6 +220,11 @@ function Editor(config) {
cm.replaceSelection(" ".repeat(num), "end", "+input");
};
// Allow add-ons to inject scripts for their editor instances
if (!this.config.externalScripts) {
this.config.externalScripts = [];
}
events.decorate(this);
}
@ -258,9 +263,11 @@ Editor.prototype = {
if (!this.config.themeSwitching)
win.document.documentElement.setAttribute("force-theme", "light");
CM_SCRIPTS.forEach((url) =>
Services.scriptloader.loadSubScript(url, win, "utf8"));
let scriptsToInject = CM_SCRIPTS.concat(this.config.externalScripts);
scriptsToInject.forEach((url) => {
if (url.startsWith("chrome://"))
Services.scriptloader.loadSubScript(url, win, "utf8");
});
// Replace the propertyKeywords, colorKeywords and valueKeywords
// properties of the CSS MIME type with the values provided by Gecko.
let cssSpec = win.CodeMirror.resolveMode("text/css");
@ -335,6 +342,11 @@ Editor.prototype = {
this._prefObserver.on(ENABLE_CODE_FOLDING, this.reloadPreferences);
this.reloadPreferences();
win.editor = this;
let editorReadyEvent = new win.CustomEvent("editorReady");
win.dispatchEvent(editorReadyEvent);
def.resolve();
};

Просмотреть файл

@ -9,6 +9,8 @@ support-files =
cm_mode_test.css
cm_mode_test.js
cm_multi_test.js
cm_mode_ruby.js
cm_script_injection_test.js
cm_search_test.js
cm_sublime_test.js
cm_test.js
@ -31,6 +33,7 @@ support-files =
[browser_editor_markers.js]
[browser_editor_movelines.js]
[browser_editor_prefs.js]
[browser_editor_script_injection.js]
[browser_editor_addons.js]
[browser_codemirror.js]
[browser_css_autocompletion.js]

Просмотреть файл

@ -0,0 +1,26 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Test the externalScripts option, which allows custom language modes or
// other scripts to be injected into the editor window. See Bug 1089428.
"use strict";
add_task(function*() {
yield runTest();
});
function* runTest() {
const baseURL = "chrome://mochitests/content/browser/browser/devtools/sourceeditor/test"
const injectedText = "Script successfully injected !";
let {ed, win} = yield setup(null, {
mode: "ruby",
externalScripts: [`${baseURL}/cm_script_injection_test.js`,
`${baseURL}/cm_mode_ruby.js`]
});
is(ed.getText(), injectedText, "The text has been injected");
is(ed.getOption("mode"), "ruby", "The ruby mode is correctly set");
teardown(ed, win);
}

Просмотреть файл

@ -0,0 +1,285 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
CodeMirror.defineMode("ruby", function(config) {
function wordObj(words) {
var o = {};
for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true;
return o;
}
var keywords = wordObj([
"alias", "and", "BEGIN", "begin", "break", "case", "class", "def", "defined?", "do", "else",
"elsif", "END", "end", "ensure", "false", "for", "if", "in", "module", "next", "not", "or",
"redo", "rescue", "retry", "return", "self", "super", "then", "true", "undef", "unless",
"until", "when", "while", "yield", "nil", "raise", "throw", "catch", "fail", "loop", "callcc",
"caller", "lambda", "proc", "public", "protected", "private", "require", "load",
"require_relative", "extend", "autoload", "__END__", "__FILE__", "__LINE__", "__dir__"
]);
var indentWords = wordObj(["def", "class", "case", "for", "while", "module", "then",
"catch", "loop", "proc", "begin"]);
var dedentWords = wordObj(["end", "until"]);
var matching = {"[": "]", "{": "}", "(": ")"};
var curPunc;
function chain(newtok, stream, state) {
state.tokenize.push(newtok);
return newtok(stream, state);
}
function tokenBase(stream, state) {
curPunc = null;
if (stream.sol() && stream.match("=begin") && stream.eol()) {
state.tokenize.push(readBlockComment);
return "comment";
}
if (stream.eatSpace()) return null;
var ch = stream.next(), m;
if (ch == "`" || ch == "'" || ch == '"') {
return chain(readQuoted(ch, "string", ch == '"' || ch == "`"), stream, state);
} else if (ch == "/") {
var currentIndex = stream.current().length;
if (stream.skipTo("/")) {
var search_till = stream.current().length;
stream.backUp(stream.current().length - currentIndex);
var balance = 0; // balance brackets
while (stream.current().length < search_till) {
var chchr = stream.next();
if (chchr == "(") balance += 1;
else if (chchr == ")") balance -= 1;
if (balance < 0) break;
}
stream.backUp(stream.current().length - currentIndex);
if (balance == 0)
return chain(readQuoted(ch, "string-2", true), stream, state);
}
return "operator";
} else if (ch == "%") {
var style = "string", embed = true;
if (stream.eat("s")) style = "atom";
else if (stream.eat(/[WQ]/)) style = "string";
else if (stream.eat(/[r]/)) style = "string-2";
else if (stream.eat(/[wxq]/)) { style = "string"; embed = false; }
var delim = stream.eat(/[^\w\s=]/);
if (!delim) return "operator";
if (matching.propertyIsEnumerable(delim)) delim = matching[delim];
return chain(readQuoted(delim, style, embed, true), stream, state);
} else if (ch == "#") {
stream.skipToEnd();
return "comment";
} else if (ch == "<" && (m = stream.match(/^<-?[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) {
return chain(readHereDoc(m[1]), stream, state);
} else if (ch == "0") {
if (stream.eat("x")) stream.eatWhile(/[\da-fA-F]/);
else if (stream.eat("b")) stream.eatWhile(/[01]/);
else stream.eatWhile(/[0-7]/);
return "number";
} else if (/\d/.test(ch)) {
stream.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+\-]?[\d_]+)?/);
return "number";
} else if (ch == "?") {
while (stream.match(/^\\[CM]-/)) {}
if (stream.eat("\\")) stream.eatWhile(/\w/);
else stream.next();
return "string";
} else if (ch == ":") {
if (stream.eat("'")) return chain(readQuoted("'", "atom", false), stream, state);
if (stream.eat('"')) return chain(readQuoted('"', "atom", true), stream, state);
// :> :>> :< :<< are valid symbols
if (stream.eat(/[\<\>]/)) {
stream.eat(/[\<\>]/);
return "atom";
}
// :+ :- :/ :* :| :& :! are valid symbols
if (stream.eat(/[\+\-\*\/\&\|\:\!]/)) {
return "atom";
}
// Symbols can't start by a digit
if (stream.eat(/[a-zA-Z$@_\xa1-\uffff]/)) {
stream.eatWhile(/[\w$\xa1-\uffff]/);
// Only one ? ! = is allowed and only as the last character
stream.eat(/[\?\!\=]/);
return "atom";
}
return "operator";
} else if (ch == "@" && stream.match(/^@?[a-zA-Z_\xa1-\uffff]/)) {
stream.eat("@");
stream.eatWhile(/[\w\xa1-\uffff]/);
return "variable-2";
} else if (ch == "$") {
if (stream.eat(/[a-zA-Z_]/)) {
stream.eatWhile(/[\w]/);
} else if (stream.eat(/\d/)) {
stream.eat(/\d/);
} else {
stream.next(); // Must be a special global like $: or $!
}
return "variable-3";
} else if (/[a-zA-Z_\xa1-\uffff]/.test(ch)) {
stream.eatWhile(/[\w\xa1-\uffff]/);
stream.eat(/[\?\!]/);
if (stream.eat(":")) return "atom";
return "ident";
} else if (ch == "|" && (state.varList || state.lastTok == "{" || state.lastTok == "do")) {
curPunc = "|";
return null;
} else if (/[\(\)\[\]{}\\;]/.test(ch)) {
curPunc = ch;
return null;
} else if (ch == "-" && stream.eat(">")) {
return "arrow";
} else if (/[=+\-\/*:\.^%<>~|]/.test(ch)) {
var more = stream.eatWhile(/[=+\-\/*:\.^%<>~|]/);
if (ch == "." && !more) curPunc = ".";
return "operator";
} else {
return null;
}
}
function tokenBaseUntilBrace(depth) {
if (!depth) depth = 1;
return function(stream, state) {
if (stream.peek() == "}") {
if (depth == 1) {
state.tokenize.pop();
return state.tokenize[state.tokenize.length-1](stream, state);
} else {
state.tokenize[state.tokenize.length - 1] = tokenBaseUntilBrace(depth - 1);
}
} else if (stream.peek() == "{") {
state.tokenize[state.tokenize.length - 1] = tokenBaseUntilBrace(depth + 1);
}
return tokenBase(stream, state);
};
}
function tokenBaseOnce() {
var alreadyCalled = false;
return function(stream, state) {
if (alreadyCalled) {
state.tokenize.pop();
return state.tokenize[state.tokenize.length-1](stream, state);
}
alreadyCalled = true;
return tokenBase(stream, state);
};
}
function readQuoted(quote, style, embed, unescaped) {
return function(stream, state) {
var escaped = false, ch;
if (state.context.type === 'read-quoted-paused') {
state.context = state.context.prev;
stream.eat("}");
}
while ((ch = stream.next()) != null) {
if (ch == quote && (unescaped || !escaped)) {
state.tokenize.pop();
break;
}
if (embed && ch == "#" && !escaped) {
if (stream.eat("{")) {
if (quote == "}") {
state.context = {prev: state.context, type: 'read-quoted-paused'};
}
state.tokenize.push(tokenBaseUntilBrace());
break;
} else if (/[@\$]/.test(stream.peek())) {
state.tokenize.push(tokenBaseOnce());
break;
}
}
escaped = !escaped && ch == "\\";
}
return style;
};
}
function readHereDoc(phrase) {
return function(stream, state) {
if (stream.match(phrase)) state.tokenize.pop();
else stream.skipToEnd();
return "string";
};
}
function readBlockComment(stream, state) {
if (stream.sol() && stream.match("=end") && stream.eol())
state.tokenize.pop();
stream.skipToEnd();
return "comment";
}
return {
startState: function() {
return {tokenize: [tokenBase],
indented: 0,
context: {type: "top", indented: -config.indentUnit},
continuedLine: false,
lastTok: null,
varList: false};
},
token: function(stream, state) {
if (stream.sol()) state.indented = stream.indentation();
var style = state.tokenize[state.tokenize.length-1](stream, state), kwtype;
var thisTok = curPunc;
if (style == "ident") {
var word = stream.current();
style = state.lastTok == "." ? "property"
: keywords.propertyIsEnumerable(stream.current()) ? "keyword"
: /^[A-Z]/.test(word) ? "tag"
: (state.lastTok == "def" || state.lastTok == "class" || state.varList) ? "def"
: "variable";
if (style == "keyword") {
thisTok = word;
if (indentWords.propertyIsEnumerable(word)) kwtype = "indent";
else if (dedentWords.propertyIsEnumerable(word)) kwtype = "dedent";
else if ((word == "if" || word == "unless") && stream.column() == stream.indentation())
kwtype = "indent";
else if (word == "do" && state.context.indented < state.indented)
kwtype = "indent";
}
}
if (curPunc || (style && style != "comment")) state.lastTok = thisTok;
if (curPunc == "|") state.varList = !state.varList;
if (kwtype == "indent" || /[\(\[\{]/.test(curPunc))
state.context = {prev: state.context, type: curPunc || style, indented: state.indented};
else if ((kwtype == "dedent" || /[\)\]\}]/.test(curPunc)) && state.context.prev)
state.context = state.context.prev;
if (stream.eol())
state.continuedLine = (curPunc == "\\" || style == "operator");
return style;
},
indent: function(state, textAfter) {
if (state.tokenize[state.tokenize.length-1] != tokenBase) return 0;
var firstChar = textAfter && textAfter.charAt(0);
var ct = state.context;
var closing = ct.type == matching[firstChar] ||
ct.type == "keyword" && /^(?:end|until|else|elsif|when|rescue)\b/.test(textAfter);
return ct.indented + (closing ? 0 : config.indentUnit) +
(state.continuedLine ? config.indentUnit : 0);
},
electricChars: "}de", // enD and rescuE
lineComment: "#"
};
});
CodeMirror.defineMIME("text/x-ruby", "ruby");
});

Просмотреть файл

@ -0,0 +1,3 @@
window.addEventListener("editorReady", function(event) {
editor.setText("Script successfully injected !");
});

Просмотреть файл

@ -54,7 +54,7 @@
<div class="devtools-searchbox">
<input id="computedview-searchbox"
class="devtools-searchinput devtools-rule-searchbox"
type="search" placeholder="&userStylesSearch;"/>
type="search" placeholder="&filterStylesPlaceholder;"/>
<button id="computedview-searchinput-clear" class="devtools-searchinput-clear"></button>
</div>
<xul:checkbox id="browser-style-checkbox"

Просмотреть файл

@ -42,7 +42,7 @@
<div class="devtools-searchbox">
<input id="ruleview-searchbox"
class="devtools-searchinput devtools-rule-searchbox"
type="search" placeholder="&userStylesSearch;"/>
type="search" placeholder="&filterStylesPlaceholder;"/>
<button id="ruleview-searchinput-clear" class="devtools-searchinput-clear"></button>
</div>
</div>

Просмотреть файл

@ -13,9 +13,9 @@
- should be displayed or not. -->
<!ENTITY browserStylesLabel "Browser styles">
<!-- LOCALIZATION NOTE (userStylesSearch): This is the placeholder that goes in
<!-- LOCALIZATION NOTE (filterStylesPlaceholder): This is the placeholder that goes in
- the search box when no search term has been entered. -->
<!ENTITY userStylesSearch "Filter Styles">
<!ENTITY filterStylesPlaceholder "Filter Styles">
<!-- LOCALIZATION NOTE (selectedElementLabel): This is the label for the path of
- the highlighted element in the web page. This path is based on the document

Просмотреть файл

@ -388,6 +388,13 @@ EXTRA_COMPONENTS += [
'SlowScriptDebug.manifest',
]
# Firefox for Android provides an alternate version of this component
if CONFIG['MOZ_BUILD_APP'] != 'mobile/android':
EXTRA_COMPONENTS += [
'SiteSpecificUserAgent.js',
'SiteSpecificUserAgent.manifest',
]
EXTRA_JS_MODULES += [
'DOMRequestHelper.jsm',
'IndexedDBHelper.jsm',

Просмотреть файл

@ -39,4 +39,15 @@ interface MozSelfSupport
* Resolved when the FHR payload data has been collected.
*/
Promise<object> getHealthReportPayload();
/**
* Resets a named pref:
* - if there is a default value, then change the value back to default,
* - if there's no default value, then delete the pref,
* - no-op otherwise.
*
* @param DOMString
* The name of the pref to reset.
*/
void resetPref(DOMString name);
};

Просмотреть файл

@ -40,7 +40,7 @@ public class TabQueueDispatcher extends Locales.LocaleAwareActivity {
// the tab queue build flag.
if (!AppConstants.MOZ_ANDROID_TAB_QUEUE) {
loadNormally(intent.getUnsafe());
finish();
return;
}
// The URL is usually hiding somewhere in the extra text. Extract it.
@ -50,13 +50,6 @@ public class TabQueueDispatcher extends Locales.LocaleAwareActivity {
return;
}
// TODO: This code is shared with ShareDialog - we should extract this to a helper class.
final String pageUrl = new WebURLFinder(dataString).bestWebURL();
if (TextUtils.isEmpty(pageUrl)) {
abortDueToNoURL(dataString);
return;
}
boolean shouldShowOpenInBackgroundToast = GeckoSharedPrefs.forApp(this).getBoolean(GeckoPreferences.PREFS_TAB_QUEUE, false);
if (shouldShowOpenInBackgroundToast) {

Просмотреть файл

@ -23,11 +23,11 @@ this.initTestLogging = function initTestLogging(level) {
this.errorsLogged += 1;
}
return message.loggerName + "\t" + message.levelDesc + "\t" +
message.message + "\n";
return message.time + "\t" + message.loggerName + "\t" + message.levelDesc + "\t" +
this.formatText(message) + "\n";
}
};
LogStats.prototype.__proto__ = new Log.Formatter();
LogStats.prototype.__proto__ = new Log.BasicFormatter();
let log = Log.repository.rootLogger;
let logStats = new LogStats();

Просмотреть файл

@ -198,7 +198,7 @@ function addPageBook(aURI, aTitle, aBook, aTags, aKey, aTransitionType, aNoVisit
gNextTestSetupTasks.push([task_addPageBook, arguments]);
}
function task_addPageBook(aURI, aTitle, aBook, aTags, aKey, aTransitionType, aNoVisit)
function* task_addPageBook(aURI, aTitle, aBook, aTags, aKey, aTransitionType, aNoVisit)
{
// Add a page entry for the current uri
gPages[aURI] = [aURI, aBook != undefined ? aBook : aTitle, aTags];
@ -230,7 +230,7 @@ function task_addPageBook(aURI, aTitle, aBook, aTags, aKey, aTransitionType, aNo
// Add a keyword to the bookmark if we need to
if (aKey != undefined)
bmsvc.setKeywordForBookmark(bmid, aKey);
yield PlacesUtils.keywords.insert({url: uri.spec, keyword: aKey});
// Add tags if we need to
if (aTags != undefined && aTags.length > 0) {

Просмотреть файл

@ -67,18 +67,16 @@ add_task(function () {
let count = getPlacesItemsCount();
// Create Bookmark
let bookmarkTitle = "title " + windowsToClose.length;
let bookmarkKeyword = "keyword " + windowsToClose.length;
let bookmarkUri = NetUtil.newURI("http://test-a-" + windowsToClose.length + ".com/");
let title = "title " + windowsToClose.length;
let keyword = "keyword " + windowsToClose.length;
let url = "http://test-a-" + windowsToClose.length + ".com/";
let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarksMenuFolderId,
bookmarkUri,
PlacesUtils.bookmarks.DEFAULT_INDEX,
bookmarkTitle);
PlacesUtils.bookmarks.setKeywordForBookmark(id, bookmarkKeyword);
yield PlacesUtils.bookmarks.insert({ url, title,
parentGuid: PlacesUtils.bookmarks.menuGuid });
yield PlacesUtils.keywords.insert({ url, keyword });
count++;
ok(PlacesUtils.bookmarks.isBookmarked(bookmarkUri),
ok((yield PlacesUtils.bookmarks.fetch({ url })),
"Bookmark should be bookmarked, data should be retrievable");
is(getPlacesItemsCount(), count,
"Check the new bookmark items count");

Просмотреть файл

@ -133,7 +133,7 @@ function task_populateDB(aArray)
if (qdata.isFolder) {
yield PlacesUtils.bookmarks.insert({
parentGuid: (yield PlacesUtils.promiseItemGuid(qdata.parentFolder)),
parentGuid: qdata.parentGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
title: qdata.title,
index: qdata.index
@ -141,17 +141,17 @@ function task_populateDB(aArray)
}
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);
yield PlacesUtils.livemarks.addLivemark({ title: qdata.title
, parentId: (yield PlacesUtils.promiseItemId(qdata.parentGuid))
, index: qdata.index
, feedURI: uri(qdata.feedURI)
, siteURI: uri(qdata.uri)
});
}
if (qdata.isBookmark) {
let data = {
parentGuid: (yield PlacesUtils.promiseItemGuid(qdata.parentFolder)),
parentGuid: qdata.parentGuid,
index: qdata.index,
title: qdata.title,
url: qdata.uri
@ -168,8 +168,8 @@ function task_populateDB(aArray)
let item = yield PlacesUtils.bookmarks.insert(data);
if (qdata.keyword) {
let itemId = yield PlacesUtils.promiseItemId(item.guid);
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, qdata.keyword);
yield PlacesUtils.keywords.insert({ url: qdata.uri,
keyword: qdata.keyword });
}
}
@ -179,7 +179,7 @@ function task_populateDB(aArray)
if (qdata.isSeparator) {
yield PlacesUtils.bookmarks.insert({
parentGuid: (yield PlacesUtils.promiseItemGuid(qdata.parentFolder)),
parentGuid: qdata.parentGuid,
type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
index: qdata.index
});
@ -227,8 +227,7 @@ function queryData(obj) {
this.isTag = obj.isTag ? obj.isTag : false;
this.tagArray = obj.tagArray ? obj.tagArray : null;
this.isLivemark = obj.isLivemark ? obj.isLivemark : false;
this.parentFolder = obj.parentFolder ? obj.parentFolder
: PlacesUtils.placesRootId;
this.parentGuid = obj.parentGuid || PlacesUtils.bookmarks.rootGuid;
this.feedURI = obj.feedURI ? obj.feedURI : "";
this.index = obj.index ? obj.index : PlacesUtils.bookmarks.DEFAULT_INDEX;
this.isFolder = obj.isFolder ? obj.isFolder : false;

Просмотреть файл

@ -268,17 +268,20 @@ let DataHelper = {
defaults: {
bookmark: {
parent: PlacesUtils.bookmarks.unfiledBookmarksFolder,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
uri: "http://example.com/",
title: "test bookmark"
},
folder: {
parent: PlacesUtils.bookmarks.unfiledBookmarksFolder,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
title: "test folder"
},
separator: {
parent: PlacesUtils.bookmarks.unfiledBookmarksFolder
parent: PlacesUtils.bookmarks.unfiledBookmarksFolder,
parentGuid: PlacesUtils.bookmarks.unfiledGuid
}
},
@ -300,7 +303,7 @@ let DataHelper = {
return {
isBookmark: true,
uri: dat.uri,
parentFolder: dat.parent,
parentGuid: dat.parentGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: dat.title,
isInQuery: true
@ -308,14 +311,14 @@ let DataHelper = {
case "separator":
return {
isSeparator: true,
parentFolder: dat.parent,
parentGuid: dat.parentGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
isInQuery: true
};
case "folder":
return {
isFolder: true,
parentFolder: dat.parent,
parentGuid: dat.parentGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: dat.title,
isInQuery: true

Просмотреть файл

@ -12,7 +12,7 @@ let gTestData = [
lastVisit: gNow,
isInQuery: true,
isBookmark: true,
parentFolder: PlacesUtils.unfiledBookmarksFolderId,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "example1",
},
@ -22,7 +22,7 @@ let gTestData = [
lastVisit: gNow++,
isInQuery: true,
isBookmark: true,
parentFolder: PlacesUtils.unfiledBookmarksFolderId,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "example2",
},
@ -32,7 +32,7 @@ let gTestData = [
lastVisit: gNow++,
isInQuery: true,
isBookmark: true,
parentFolder: PlacesUtils.unfiledBookmarksFolderId,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "example3",
},

Просмотреть файл

@ -20,14 +20,14 @@ var testData = [
// Add a bookmark that should be in the results
{ isBookmark: true,
uri: "http://bookmarked.com/",
parentFolder: PlacesUtils.toolbarFolderId,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
isInQuery: true },
// Add a bookmark that should not be in the results
{ isBookmark: true,
uri: "http://bookmarked-elsewhere.com/",
parentFolder: PlacesUtils.bookmarksMenuFolderId,
parentGuid: PlacesUtils.bookmarks.menuGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
isInQuery: false },
@ -82,14 +82,14 @@ add_task(function test_onlyBookmarked()
//Add a bookmark that should show up
{ isBookmark: true,
uri: "http://bookmarked2.com/",
parentFolder: PlacesUtils.toolbarFolderId,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
isInQuery: true },
//Add a bookmark that should not show up
{ isBookmark: true,
uri: "http://bookmarked-elsewhere2.com/",
parentFolder: PlacesUtils.bookmarksMenuFolderId,
parentGuid: PlacesUtils.bookmarks.menuGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
isInQuery: false }
];

Просмотреть файл

@ -271,7 +271,7 @@ add_task(function test_add_visits_to_database()
// Add an unvisited bookmark in the database, it should never appear.
visits.push({ isBookmark: true,
uri: "http://unvisited.bookmark.com/",
parentFolder: PlacesUtils.bookmarksMenuFolderId,
parentGuid: PlacesUtils.bookmarks.menuGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "Unvisited Bookmark",
isInQuery: false });

Просмотреть файл

@ -17,7 +17,7 @@ tests.push({
this._unsortedData = [
{ isBookmark: true,
uri: "http://example.com/b",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "y",
keyword: "b",
@ -25,7 +25,7 @@ tests.push({
{ isBookmark: true,
uri: "http://example.com/a",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "z",
keyword: "a",
@ -33,7 +33,7 @@ tests.push({
{ isBookmark: true,
uri: "http://example.com/c",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "x",
keyword: "c",
@ -80,21 +80,21 @@ tests.push({
this._unsortedData = [
{ isBookmark: true,
uri: "http://example.com/b1",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "y",
isInQuery: true },
{ isBookmark: true,
uri: "http://example.com/a",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "z",
isInQuery: true },
{ isBookmark: true,
uri: "http://example.com/c",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "x",
isInQuery: true },
@ -102,7 +102,7 @@ tests.push({
// if titles are equal, should fall back to URI
{ isBookmark: true,
uri: "http://example.com/b2",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "y",
isInQuery: true },
@ -157,7 +157,7 @@ tests.push({
{ isVisit: true,
isDetails: true,
isBookmark: true,
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 0,
uri: "http://example.com/c1",
lastVisit: timeInMicroseconds - 2,
@ -167,7 +167,7 @@ tests.push({
{ isVisit: true,
isDetails: true,
isBookmark: true,
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 1,
uri: "http://example.com/a",
lastVisit: timeInMicroseconds - 1,
@ -177,7 +177,7 @@ tests.push({
{ isVisit: true,
isDetails: true,
isBookmark: true,
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 2,
uri: "http://example.com/b",
lastVisit: timeInMicroseconds - 3,
@ -188,7 +188,7 @@ tests.push({
{ isVisit: true,
isDetails: true,
isBookmark: true,
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 3,
uri: "http://example.com/c2",
lastVisit: timeInMicroseconds - 2,
@ -199,7 +199,7 @@ tests.push({
{ isVisit: true,
isDetails: true,
isBookmark: true,
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 4,
uri: "http://example.com/c2",
lastVisit: timeInMicroseconds - 2,
@ -258,21 +258,21 @@ tests.push({
isDetails: true,
lastVisit: timeInMicroseconds,
uri: "http://example.com/b",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 0,
title: "y",
isInQuery: true },
{ isBookmark: true,
uri: "http://example.com/c",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 1,
title: "x",
isInQuery: true },
{ isBookmark: true,
uri: "http://example.com/a",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 2,
title: "z",
isInQuery: true },
@ -282,14 +282,14 @@ tests.push({
isDetails: true,
lastVisit: timeInMicroseconds + 1000,
uri: "http://example.com/c",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 3,
title: "x",
isInQuery: true },
// if no URI (e.g., node is a folder), should fall back to title
{ isFolder: true,
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 4,
title: "a",
isInQuery: true },
@ -299,14 +299,14 @@ tests.push({
isDetails: true,
lastVisit: timeInMicroseconds + 1000,
uri: "http://example.com/c",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 5,
title: "x",
isInQuery: true },
// if no URI and titles are equal, should fall back to bookmark index
{ isFolder: true,
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 6,
title: "a",
isInQuery: true },
@ -364,7 +364,7 @@ tests.push({
uri: "http://example.com/a",
lastVisit: timeInMicroseconds,
title: "z",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 0,
isInQuery: true },
@ -372,7 +372,7 @@ tests.push({
uri: "http://example.com/c",
lastVisit: timeInMicroseconds,
title: "x",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 1,
isInQuery: true },
@ -380,7 +380,7 @@ tests.push({
uri: "http://example.com/b1",
lastVisit: timeInMicroseconds,
title: "y1",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 2,
isInQuery: true },
@ -389,7 +389,7 @@ tests.push({
uri: "http://example.com/b2",
lastVisit: timeInMicroseconds + 1000,
title: "y2a",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 3,
isInQuery: true },
@ -398,7 +398,7 @@ tests.push({
uri: "http://example.com/b2",
lastVisit: timeInMicroseconds + 1000,
title: "y2b",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 4,
isInQuery: true },
];
@ -462,7 +462,7 @@ tests.push({
this._unsortedData = [
{ isBookmark: true,
uri: "http://example.com/a",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "z",
keyword: "a",
@ -470,7 +470,7 @@ tests.push({
{ isBookmark: true,
uri: "http://example.com/c",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "x",
keyword: "c",
@ -478,7 +478,7 @@ tests.push({
{ isBookmark: true,
uri: "http://example.com/b1",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "y9",
keyword: "b",
@ -487,7 +487,7 @@ tests.push({
// without a keyword, should fall back to title
{ isBookmark: true,
uri: "http://example.com/null2",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "null8",
keyword: null,
@ -496,7 +496,7 @@ tests.push({
// without a keyword, should fall back to title
{ isBookmark: true,
uri: "http://example.com/null1",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "null9",
keyword: null,
@ -505,7 +505,7 @@ tests.push({
// if keywords are equal, should fall back to title
{ isBookmark: true,
uri: "http://example.com/b1",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "y8",
keyword: "b",
@ -562,7 +562,7 @@ tests.push({
this._unsortedData = [
{ isBookmark: true,
uri: "http://example.com/b1",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 0,
title: "y1",
dateAdded: timeInMicroseconds - 1000,
@ -570,7 +570,7 @@ tests.push({
{ isBookmark: true,
uri: "http://example.com/a",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 1,
title: "z",
dateAdded: timeInMicroseconds - 2000,
@ -578,7 +578,7 @@ tests.push({
{ isBookmark: true,
uri: "http://example.com/c",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 2,
title: "x",
dateAdded: timeInMicroseconds,
@ -587,7 +587,7 @@ tests.push({
// if dateAddeds are equal, should fall back to title
{ isBookmark: true,
uri: "http://example.com/b2",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 3,
title: "y2",
dateAdded: timeInMicroseconds - 1000,
@ -596,7 +596,7 @@ tests.push({
// if dateAddeds and titles are equal, should fall back to bookmark index
{ isBookmark: true,
uri: "http://example.com/b3",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 4,
title: "y3",
dateAdded: timeInMicroseconds - 1000,
@ -654,7 +654,7 @@ tests.push({
this._unsortedData = [
{ isBookmark: true,
uri: "http://example.com/b1",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 0,
title: "y1",
dateAdded: timeAddedInMicroseconds,
@ -663,7 +663,7 @@ tests.push({
{ isBookmark: true,
uri: "http://example.com/a",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 1,
title: "z",
dateAdded: timeAddedInMicroseconds,
@ -672,7 +672,7 @@ tests.push({
{ isBookmark: true,
uri: "http://example.com/c",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 2,
title: "x",
dateAdded: timeAddedInMicroseconds,
@ -682,7 +682,7 @@ tests.push({
// if lastModifieds are equal, should fall back to title
{ isBookmark: true,
uri: "http://example.com/b2",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 3,
title: "y2",
dateAdded: timeAddedInMicroseconds,
@ -693,7 +693,7 @@ tests.push({
// index
{ isBookmark: true,
uri: "http://example.com/b3",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 4,
title: "y3",
dateAdded: timeAddedInMicroseconds,
@ -749,7 +749,7 @@ tests.push({
this._unsortedData = [
{ isBookmark: true,
uri: "http://url2.com/",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "title x",
isTag: true,
@ -758,7 +758,7 @@ tests.push({
{ isBookmark: true,
uri: "http://url1a.com/",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "title y1",
isTag: true,
@ -767,14 +767,14 @@ tests.push({
{ isBookmark: true,
uri: "http://url3a.com/",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "title w1",
isInQuery: true },
{ isBookmark: true,
uri: "http://url0.com/",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "title z",
isTag: true,
@ -784,7 +784,7 @@ tests.push({
// if tags are equal, should fall back to title
{ isBookmark: true,
uri: "http://url1b.com/",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "title y2",
isTag: true,
@ -794,7 +794,7 @@ tests.push({
// if tags are equal, should fall back to title
{ isBookmark: true,
uri: "http://url3b.com/",
parentFolder: PlacesUtils.bookmarks.toolbarFolder,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
title: "title w2",
isInQuery: true },

Просмотреть файл

@ -10,6 +10,19 @@ let annosvc = PlacesUtils.annotations;
let txnManager = PlacesUtils.transactionManager;
const DESCRIPTION_ANNO = "bookmarkProperties/description";
function* promiseKeyword(keyword, href, postData) {
while (true) {
let entry = yield PlacesUtils.keywords.fetch(keyword);
if (href == null && !entry)
break;
if (entry && entry.url.href == href && entry.postData == postData) {
break;
}
yield new Promise(resolve => do_timeout(100, resolve));
}
}
// create and add bookmarks observer
let observer = {
@ -97,16 +110,14 @@ let bmStartIndex = 0;
// get bookmarks root id
let root = PlacesUtils.bookmarksMenuFolderId;
function run_test() {
add_task(function* init() {
bmsvc.addObserver(observer, false);
do_register_cleanup(function () {
bmsvc.removeObserver(observer);
});
});
run_next_test();
}
add_test(function test_create_folder_with_description() {
add_task(function* test_create_folder_with_description() {
const TEST_FOLDERNAME = "Test creating a folder with a description";
const TEST_DESCRIPTION = "this is my test description";
@ -145,11 +156,9 @@ add_test(function test_create_folder_with_description() {
do_check_eq(observer._itemRemovedId, folderId);
do_check_eq(observer._itemRemovedFolder, root);
do_check_eq(observer._itemRemovedIndex, bmStartIndex);
run_next_test();
});
add_test(function test_create_item() {
add_task(function* test_create_item() {
let testURI = NetUtil.newURI("http://test_create_item.com");
let txn = new PlacesCreateBookmarkTransaction(testURI, root, bmStartIndex,
@ -177,11 +186,9 @@ add_test(function test_create_item() {
do_check_eq(observer._itemRemovedId, newId);
do_check_eq(observer._itemRemovedFolder, root);
do_check_eq(observer._itemRemovedIndex, bmStartIndex);
run_next_test();
});
add_test(function test_create_item_to_folder() {
add_task(function* test_create_item_to_folder() {
const TEST_FOLDERNAME = "Test creating item to a folder";
let testURI = NetUtil.newURI("http://test_create_item_to_folder.com");
let folderId = bmsvc.createFolder(root, TEST_FOLDERNAME, bmsvc.DEFAULT_INDEX);
@ -208,11 +215,9 @@ add_test(function test_create_item_to_folder() {
do_check_eq(observer._itemRemovedId, newBkmId);
do_check_eq(observer._itemRemovedFolder, folderId);
do_check_eq(observer._itemRemovedIndex, bmStartIndex);
run_next_test();
});
add_test(function test_move_items_to_folder() {
add_task(function* test_move_items_to_folder() {
let testFolderId = bmsvc.createFolder(root, "Test move items", bmsvc.DEFAULT_INDEX);
let testURI = NetUtil.newURI("http://test_move_items.com");
let testBkmId = bmsvc.insertBookmark(testFolderId, testURI, bmsvc.DEFAULT_INDEX, "1: Test move items");
@ -282,11 +287,9 @@ add_test(function test_move_items_to_folder() {
do_check_eq(observer._itemMovedOldIndex, 0);
do_check_eq(observer._itemMovedNewParent, testFolderId);
do_check_eq(observer._itemMovedNewIndex, 0);
run_next_test();
});
add_test(function test_remove_folder() {
add_task(function* test_remove_folder() {
let testFolder = bmsvc.createFolder(root, "Test Removing a Folder", bmsvc.DEFAULT_INDEX);
let folderId = bmsvc.createFolder(testFolder, "Removed Folder", bmsvc.DEFAULT_INDEX);
@ -311,25 +314,22 @@ add_test(function test_remove_folder() {
do_check_eq(observer._itemAddedId, folderId);
do_check_eq(observer._itemAddedParent, testFolder);
do_check_eq(observer._itemAddedIndex, 0);
run_next_test();
});
add_test(function test_remove_item_with_keyword_and_tag() {
add_task(function* test_remove_item_with_tag() {
// Notice in this case the tag persists since other bookmarks have same uri.
let testFolder = bmsvc.createFolder(root, "Test removing an item with a keyword and a tag",
let testFolder = bmsvc.createFolder(root, "Test removing an item with a tag",
bmsvc.DEFAULT_INDEX);
const KEYWORD = "test: test removing an item with a keyword and a tag";
const TAG_NAME = "tag-test_remove_item_with_keyword_and_tag";
let testURI = NetUtil.newURI("http://test_remove_item_with_keyword_and_tag.com");
const KEYWORD = "test: test removing an item with a tag";
const TAG_NAME = "tag-test_remove_item_with_tag";
let testURI = NetUtil.newURI("http://test_remove_item_with_tag.com");
let testBkmId = bmsvc.insertBookmark(testFolder, testURI, bmsvc.DEFAULT_INDEX, "test-item1");
// create bookmark for not removing tag.
bmsvc.insertBookmark(testFolder, testURI, bmsvc.DEFAULT_INDEX, "test-item2");
// set tag & keyword
bmsvc.setKeywordForBookmark(testBkmId, KEYWORD);
// set tag
tagssvc.tagURI(testURI, [TAG_NAME]);
let txn = new PlacesRemoveItemTransaction(testBkmId);
@ -338,57 +338,65 @@ add_test(function test_remove_item_with_keyword_and_tag() {
do_check_eq(observer._itemRemovedId, testBkmId);
do_check_eq(observer._itemRemovedFolder, testFolder);
do_check_eq(observer._itemRemovedIndex, 0);
do_check_eq(bmsvc.getKeywordForBookmark(testBkmId), null);
do_check_eq(tagssvc.getTagsForURI(testURI)[0], TAG_NAME);
do_check_eq(tagssvc.getTagsForURI(testURI), TAG_NAME);
txn.undoTransaction();
let newbkmk2Id = observer._itemAddedId;
do_check_eq(observer._itemAddedParent, testFolder);
do_check_eq(observer._itemAddedIndex, 0);
do_check_eq(bmsvc.getKeywordForBookmark(newbkmk2Id), KEYWORD);
do_check_eq(tagssvc.getTagsForURI(testURI)[0], TAG_NAME);
txn.redoTransaction();
do_check_eq(observer._itemRemovedId, newbkmk2Id);
do_check_eq(observer._itemRemovedFolder, testFolder);
do_check_eq(observer._itemRemovedIndex, 0);
do_check_eq(bmsvc.getKeywordForBookmark(newbkmk2Id), null);
do_check_eq(tagssvc.getTagsForURI(testURI)[0], TAG_NAME);
txn.undoTransaction();
do_check_eq(observer._itemAddedParent, testFolder);
do_check_eq(observer._itemAddedIndex, 0);
do_check_eq(tagssvc.getTagsForURI(testURI)[0], TAG_NAME);
run_next_test();
});
add_test(function test_remove_item_with_tag() {
const TAG_NAME = "tag-test_remove_item_with_tag";
let testURI = NetUtil.newURI("http://test_remove_item_with_tag.com/");
let itemId = bmsvc.insertBookmark(root, testURI, bmsvc.DEFAULT_INDEX, "Test removing an item with a tag");
tagssvc.tagURI(testURI, [TAG_NAME]);
add_task(function* test_remove_item_with_keyword() {
// Notice in this case the tag persists since other bookmarks have same uri.
let testFolder = bmsvc.createFolder(root, "Test removing an item with a keyword",
bmsvc.DEFAULT_INDEX);
let txn = new PlacesRemoveItemTransaction(itemId);
const KEYWORD = "test: test removing an item with a keyword";
const TAG_NAME = "tag-test_remove_item_with_keyword";
let testURI = NetUtil.newURI("http://test_remove_item_with_keyword.com");
let testBkmId = bmsvc.insertBookmark(testFolder, testURI, bmsvc.DEFAULT_INDEX, "test-item1");
// set keyword
yield PlacesUtils.keywords.insert({ url: testURI.spec, keyword: KEYWORD});
let txn = new PlacesRemoveItemTransaction(testBkmId);
txn.doTransaction();
do_check_true(tagssvc.getTagsForURI(testURI).length == 0);
do_check_eq(observer._itemRemovedId, testBkmId);
do_check_eq(observer._itemRemovedFolder, testFolder);
do_check_eq(observer._itemRemovedIndex, 0);
yield promiseKeyword(KEYWORD, null);
txn.undoTransaction();
do_check_eq(tagssvc.getTagsForURI(testURI)[0], TAG_NAME);
let newbkmk2Id = observer._itemAddedId;
do_check_eq(observer._itemAddedParent, testFolder);
do_check_eq(observer._itemAddedIndex, 0);
yield promiseKeyword(KEYWORD, testURI.spec);
txn.redoTransaction();
do_check_true(tagssvc.getTagsForURI(testURI).length == 0);
do_check_eq(observer._itemRemovedId, newbkmk2Id);
do_check_eq(observer._itemRemovedFolder, testFolder);
do_check_eq(observer._itemRemovedIndex, 0);
yield promiseKeyword(KEYWORD, null);
txn.undoTransaction();
do_check_eq(tagssvc.getTagsForURI(testURI)[0], TAG_NAME);
txn.redoTransaction();
run_next_test();
do_check_eq(observer._itemAddedParent, testFolder);
do_check_eq(observer._itemAddedIndex, 0);
});
add_test(function test_creating_separator() {
add_task(function* test_creating_separator() {
let testFolder = bmsvc.createFolder(root, "Test creating a separator", bmsvc.DEFAULT_INDEX);
let txn = new PlacesCreateSeparatorTransaction(testFolder, 0);
@ -412,11 +420,9 @@ add_test(function test_creating_separator() {
do_check_eq(observer._itemRemovedId, newSepId);
do_check_eq(observer._itemRemovedFolder, testFolder);
do_check_eq(observer._itemRemovedIndex, 0);
run_next_test();
});
add_test(function test_removing_separator() {
add_task(function* test_removing_separator() {
let testFolder = bmsvc.createFolder(root, "Test removing a separator", bmsvc.DEFAULT_INDEX);
let sepId = bmsvc.insertSeparator(testFolder, 0);
@ -441,11 +447,9 @@ add_test(function test_removing_separator() {
do_check_eq(observer._itemAddedId, sepId); //New separator created
do_check_eq(observer._itemAddedParent, testFolder);
do_check_eq(observer._itemAddedIndex, 0);
run_next_test();
});
add_test(function test_editing_item_title() {
add_task(function* test_editing_item_title() {
const TITLE = "Test editing item title";
const MOD_TITLE = "Mod: Test editing item title";
let testURI = NetUtil.newURI("http://www.test_editing_item_title.com");
@ -472,11 +476,9 @@ add_test(function test_editing_item_title() {
do_check_eq(observer._itemChangedId, testBkmId);
do_check_eq(observer._itemChangedProperty, "title");
do_check_eq(observer._itemChangedValue, TITLE);
run_next_test();
});
add_test(function test_editing_item_uri() {
add_task(function* test_editing_item_uri() {
const OLD_TEST_URI = NetUtil.newURI("http://old.test_editing_item_uri.com/");
const NEW_TEST_URI = NetUtil.newURI("http://new.test_editing_item_uri.com/");
let testBkmId = bmsvc.insertBookmark(root, OLD_TEST_URI, bmsvc.DEFAULT_INDEX,
@ -512,11 +514,9 @@ add_test(function test_editing_item_uri() {
do_check_eq(observer._itemChangedValue, OLD_TEST_URI.spec);
do_check_eq(JSON.stringify(tagssvc.getTagsForURI(OLD_TEST_URI)), JSON.stringify(["tag"]));
do_check_eq(JSON.stringify(tagssvc.getTagsForURI(NEW_TEST_URI)), JSON.stringify([]));
run_next_test();
});
add_test(function test_edit_description_transaction() {
add_task(function* test_edit_description_transaction() {
let testURI = NetUtil.newURI("http://test_edit_description_transaction.com");
let testBkmId = bmsvc.insertBookmark(root, testURI, bmsvc.DEFAULT_INDEX, "Test edit description transaction");
@ -532,11 +532,9 @@ add_test(function test_edit_description_transaction() {
txn.doTransaction();
do_check_eq(observer._itemChangedId, testBkmId);
do_check_eq(observer._itemChangedProperty, DESCRIPTION_ANNO);
run_next_test();
});
add_test(function test_edit_keyword() {
add_task(function* test_edit_keyword() {
const KEYWORD = "keyword-test_edit_keyword";
let testURI = NetUtil.newURI("http://test_edit_keyword.com");
@ -553,11 +551,9 @@ add_test(function test_edit_keyword() {
do_check_eq(observer._itemChangedId, testBkmId);
do_check_eq(observer._itemChangedProperty, "keyword");
do_check_eq(observer._itemChangedValue, "");
run_next_test();
});
add_test(function test_LoadInSidebar_transaction() {
add_task(function* test_LoadInSidebar_transaction() {
let testURI = NetUtil.newURI("http://test_LoadInSidebar_transaction.com");
let testBkmId = bmsvc.insertBookmark(root, testURI, bmsvc.DEFAULT_INDEX, "Test LoadInSidebar transaction");
@ -578,11 +574,9 @@ add_test(function test_LoadInSidebar_transaction() {
do_check_eq(observer._itemChangedId, testBkmId);
do_check_eq(observer._itemChangedProperty, LOAD_IN_SIDEBAR_ANNO);
do_check_eq(observer._itemChanged_isAnnotationProperty, true);
run_next_test();
});
add_test(function test_generic_item_annotation() {
add_task(function* test_generic_item_annotation() {
let testURI = NetUtil.newURI("http://test_generic_item_annotation.com");
let testBkmId = bmsvc.insertBookmark(root, testURI, bmsvc.DEFAULT_INDEX, "Test generic item annotation");
@ -607,11 +601,9 @@ add_test(function test_generic_item_annotation() {
do_check_eq(observer._itemChangedId, testBkmId);
do_check_eq(observer._itemChangedProperty, "testAnno/testInt");
do_check_eq(observer._itemChanged_isAnnotationProperty, true);
run_next_test();
});
add_test(function test_editing_item_date_added() {
add_task(function* test_editing_item_date_added() {
let testURI = NetUtil.newURI("http://test_editing_item_date_added.com");
let testBkmId = bmsvc.insertBookmark(root, testURI, bmsvc.DEFAULT_INDEX,
"Test editing item date added");
@ -625,11 +617,9 @@ add_test(function test_editing_item_date_added() {
txn.undoTransaction();
do_check_eq(oldAdded, bmsvc.getItemDateAdded(testBkmId));
run_next_test();
});
add_test(function test_edit_item_last_modified() {
add_task(function* test_edit_item_last_modified() {
let testURI = NetUtil.newURI("http://test_edit_item_last_modified.com");
let testBkmId = bmsvc.insertBookmark(root, testURI, bmsvc.DEFAULT_INDEX,
"Test editing item last modified");
@ -643,11 +633,9 @@ add_test(function test_edit_item_last_modified() {
txn.undoTransaction();
do_check_eq(oldModified, bmsvc.getItemLastModified(testBkmId));
run_next_test();
});
add_test(function test_generic_page_annotation() {
add_task(function* test_generic_page_annotation() {
const TEST_ANNO = "testAnno/testInt";
let testURI = NetUtil.newURI("http://www.mozilla.org/");
PlacesTestUtils.addVisits(testURI).then(function () {
@ -666,12 +654,10 @@ add_test(function test_generic_page_annotation() {
txn.redoTransaction();
do_check_true(annosvc.pageHasAnnotation(testURI, TEST_ANNO));
run_next_test();
});
});
add_test(function test_sort_folder_by_name() {
add_task(function* test_sort_folder_by_name() {
let testFolder = bmsvc.createFolder(root, "Test PlacesSortFolderByNameTransaction",
bmsvc.DEFAULT_INDEX);
let testURI = NetUtil.newURI("http://test_sort_folder_by_name.com");
@ -712,52 +698,37 @@ add_test(function test_sort_folder_by_name() {
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() {
function* promiseKeyword(keyword, href, postData) {
while (true) {
let entry = yield PlacesUtils.keywords.fetch(keyword);
if (entry && entry.url.href == href && entry.postData == postData) {
break;
}
add_task(function* test_edit_postData() {
let postData = "post-test_edit_postData";
let testURI = NetUtil.newURI("http://test_edit_postData.com");
yield new Promise(resolve => do_timeout(100, resolve));
}
}
let testBkm = yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.menuGuid,
url: "http://test_edit_postData.com",
title: "Test edit Post Data"
});
Task.spawn(function* () {
let postData = "post-test_edit_postData";
let testURI = NetUtil.newURI("http://test_edit_postData.com");
yield PlacesUtils.keywords.insert({
keyword: "kw",
url: "http://test_edit_postData.com"
});
let testBkm = yield PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.menuGuid,
url: "http://test_edit_postData.com",
title: "Test edit Post Data"
});
let testBkmId = yield PlacesUtils.promiseItemId(testBkm.guid);
let txn = new PlacesEditBookmarkPostDataTransaction(testBkmId, postData);
yield PlacesUtils.keywords.insert({
keyword: "kw",
url: "http://test_edit_postData.com"
});
txn.doTransaction();
yield promiseKeyword("kw", testURI.spec, postData);
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);
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);
});
add_test(function test_tagURI_untagURI() {
add_task(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");
@ -785,11 +756,9 @@ add_test(function test_tagURI_untagURI() {
untagTxn.redoTransaction();
do_check_eq(JSON.stringify(tagssvc.getTagsForURI(tagURI)), JSON.stringify([TAG_2]));
run_next_test();
});
add_test(function test_aggregate_removeItem_Txn() {
add_task(function* test_aggregate_removeItem_Txn() {
let testFolder = bmsvc.createFolder(root, "Test aggregate removeItem transaction", bmsvc.DEFAULT_INDEX);
const TEST_URL = "http://test_aggregate_removeitem_txn.com/";
@ -877,11 +846,9 @@ add_test(function test_aggregate_removeItem_Txn() {
// Check last added back item id.
// Notice items are restored in reverse order.
do_check_eq(observer._itemAddedId, newBkmk1Id);
run_next_test();
});
add_test(function test_create_item_with_childTxn() {
add_task(function* test_create_item_with_childTxn() {
let testFolder = bmsvc.createFolder(root, "Test creating an item with childTxns", bmsvc.DEFAULT_INDEX);
const BOOKMARK_TITLE = "parent item";
@ -931,11 +898,9 @@ add_test(function test_create_item_with_childTxn() {
catch (ex) {
do_throw("Setting a child transaction in a createItem transaction did throw: " + ex);
}
run_next_test();
});
add_test(function test_create_folder_with_child_itemTxn() {
add_task(function* test_create_folder_with_child_itemTxn() {
let childURI = NetUtil.newURI("http://test_create_folder_with_child_itemTxn.com");
let childItemTxn = new PlacesCreateBookmarkTransaction(childURI, root,
bmStartIndex, "childItem");
@ -963,6 +928,4 @@ add_test(function test_create_folder_with_child_itemTxn() {
catch (ex) {
do_throw("Setting a child item transaction in a createFolder transaction did throw: " + ex);
}
run_next_test();
});

Просмотреть файл

@ -1166,30 +1166,32 @@ tests.push({
]);
},
asyncCheck: function(aCallback) {
let stmt = mDBConn.createAsyncStatement(
"SELECT h.url FROM moz_places h WHERE h.hidden = 1"
);
stmt.executeAsync({
_count: 0,
handleResult: function(aResultSet) {
for (let row; (row = aResultSet.getNextRow());) {
let url = row.getResultByIndex(0);
do_check_true(/redirecting/.test(url));
this._count++;
check: function () {
return new Promise(resolve => {
let stmt = mDBConn.createAsyncStatement(
"SELECT h.url FROM moz_places h WHERE h.hidden = 1"
);
stmt.executeAsync({
_count: 0,
handleResult: function(aResultSet) {
for (let row; (row = aResultSet.getNextRow());) {
let url = row.getResultByIndex(0);
do_check_true(/redirecting/.test(url));
this._count++;
}
},
handleError: function(aError) {
},
handleCompletion: function(aReason) {
dump_table("moz_places");
dump_table("moz_historyvisits");
do_check_eq(aReason, Ci.mozIStorageStatementCallback.REASON_FINISHED);
do_check_eq(this._count, 2);
resolve();
}
},
handleError: function(aError) {
},
handleCompletion: function(aReason) {
dump_table("moz_places");
dump_table("moz_historyvisits");
do_check_eq(aReason, Ci.mozIStorageStatementCallback.REASON_FINISHED);
do_check_eq(this._count, 2);
aCallback();
}
});
stmt.finalize();
});
stmt.finalize();
}
});
@ -1205,7 +1207,7 @@ tests.push({
_bookmarkId: null,
_separatorId: null,
setup: function() {
setup: function* () {
// use valid api calls to create a bunch of items
yield PlacesTestUtils.addVisits([
{ uri: this._uri1 },
@ -1224,36 +1226,35 @@ tests.push({
ts.tagURI(this._uri1, ["testtag"]);
fs.setAndFetchFaviconForPage(this._uri2, SMALLPNG_DATA_URI, false,
PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE);
bs.setKeywordForBookmark(this._bookmarkId, "testkeyword");
yield PlacesUtils.keywords.insert({ url: this._uri1.spec, keyword: "testkeyword" });
as.setPageAnnotation(this._uri2, "anno", "anno", 0, as.EXPIRE_NEVER);
as.setItemAnnotation(this._bookmarkId, "anno", "anno", 0, as.EXPIRE_NEVER);
},
asyncCheck: function (aCallback) {
check: Task.async(function* () {
// Check that all items are correct
PlacesUtils.asyncHistory.isURIVisited(this._uri1, function(aURI, aIsVisited) {
do_check_true(aIsVisited);
PlacesUtils.asyncHistory.isURIVisited(this._uri2, function(aURI, aIsVisited) {
do_check_true(aIsVisited);
let isVisited = yield promiseIsURIVisited(this._uri1);
do_check_true(isVisited);
isVisited = yield promiseIsURIVisited(this._uri2);
do_check_true(isVisited);
do_check_eq(bs.getBookmarkURI(this._bookmarkId).spec, this._uri1.spec);
do_check_eq(bs.getItemIndex(this._folderId), 0);
do_check_eq(bs.getBookmarkURI(this._bookmarkId).spec, this._uri1.spec);
do_check_eq(bs.getItemIndex(this._folderId), 0);
do_check_eq(bs.getItemType(this._folderId), bs.TYPE_FOLDER);
do_check_eq(bs.getItemType(this._separatorId), bs.TYPE_SEPARATOR);
do_check_eq(bs.getItemType(this._folderId), bs.TYPE_FOLDER);
do_check_eq(bs.getItemType(this._separatorId), bs.TYPE_SEPARATOR);
do_check_eq(ts.getTagsForURI(this._uri1).length, 1);
do_check_eq((yield PlacesUtils.keywords.fetch({ url: this._uri1.spec })).keyword, "testkeyword");
do_check_eq(as.getPageAnnotation(this._uri2, "anno"), "anno");
do_check_eq(as.getItemAnnotation(this._bookmarkId, "anno"), "anno");
do_check_eq(ts.getTagsForURI(this._uri1).length, 1);
do_check_eq(bs.getKeywordForBookmark(this._bookmarkId), "testkeyword");
do_check_eq(as.getPageAnnotation(this._uri2, "anno"), "anno");
do_check_eq(as.getItemAnnotation(this._bookmarkId, "anno"), "anno");
fs.getFaviconURLForPage(this._uri2, function (aFaviconURI) {
do_check_true(aFaviconURI.equals(SMALLPNG_DATA_URI));
aCallback();
});
}.bind(this));
}.bind(this));
}
yield new Promise(resolve => {
fs.getFaviconURLForPage(this._uri2, aFaviconURI => {
do_check_true(aFaviconURI.equals(SMALLPNG_DATA_URI));
resolve();
});
});
})
});
//------------------------------------------------------------------------------
@ -1290,13 +1291,7 @@ add_task(function test_preventive_maintenance()
// Check the lastMaintenance time has been saved.
do_check_neq(Services.prefs.getIntPref("places.database.lastMaintenance"), null);
if (test.asyncCheck) {
let deferred = Promise.defer();
test.asyncCheck(deferred.resolve);
yield deferred.promise;
} else {
test.check();
}
yield test.check();
cleanDatabase();
}

Просмотреть файл

@ -147,9 +147,9 @@ function* compareToNode(aItem, aNode, aIsRootItem, aExcludedGuids = []) {
let itemURI = uri(aNode.uri);
compare_prop_to_value("charset",
yield PlacesUtils.getCharsetForURI(itemURI));
compare_prop_to_value("keyword",
PlacesUtils.bookmarks
.getKeywordForBookmark(aNode.itemId));
let entry = yield PlacesUtils.keywords.fetch({ url: aNode.uri });
compare_prop_to_value("keyword", entry ? entry.keyword : null);
if ("title" in aItem)
compare_prop("title");
@ -251,7 +251,3 @@ add_task(function* () {
do_check_eq(guidsPassedToExcludeCallback.size, 4);
do_check_eq(placesRootWithoutTheMenu.children.length, 2);
});
function run_test() {
run_next_test();
}

Просмотреть файл

@ -86,8 +86,8 @@ add_task(function test() {
do_print("Sort by keyword asc");
result.sortingMode = NHQO.SORT_BY_KEYWORD_ASCENDING;
checkOrder(id3, id2, id1); // no keywords set - falling back to title sort
PlacesUtils.bookmarks.setKeywordForBookmark(id1, "a");
PlacesUtils.bookmarks.setKeywordForBookmark(id2, "z");
yield PlacesUtils.keywords.insert({ url: uri1.spec, keyword: "a" });
yield PlacesUtils.keywords.insert({ url: uri2.spec, keyword: "z" });
checkOrder(id3, id1, id2);
// XXXtodo: test history sortings (visit count, visit date)

Просмотреть файл

@ -42,7 +42,7 @@ add_task(function test_execute()
PlacesUtils.bookmarks.DEFAULT_INDEX,
"moz test");
PlacesUtils.tagging.tagURI(uri, ["tag"]);
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, "keyword");
yield PlacesUtils.keywords.insert({ url: uri.spec, keyword: "keyword"});
// Set a large annotation.
let content = "";

Просмотреть файл

@ -14,6 +14,9 @@ const { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
const { promiseInvoke } = devtools.require("devtools/async-utils");
const Services = devtools.require("Services");
// Always log packets when running tests. runxpcshelltests.py will throw
// the output away anyway, unless you give it the --verbose flag.
Services.prefs.setBoolPref("devtools.debugger.log", true);
// Enable remote debugging for the relevant tests.
Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);

Просмотреть файл

@ -660,10 +660,8 @@ function getCanStageUpdates() {
// For Gonk, the updater will remount the /system partition to move staged
// files into place.
if (AppConstants.platform == "gonk") {
if (getPref("getBoolPref", PREF_APP_UPDATE_SERVICE_ENABLED, false)) {
LOG("getCanStageUpdates - able to stage updates because this is gonk");
LOG("getCanStageUpdates - able to stage updates because this is gonk");
return true;
}
}
if (!hasUpdateMutex()) {