This commit is contained in:
Dan Mills 2008-06-26 12:23:07 -07:00
Родитель 76c7dbd4f1 b07cfbf417
Коммит 434f582257
10 изменённых файлов: 107 добавлений и 88 удалений

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

@ -1,18 +1,16 @@
<!ENTITY serverError1.description "Server Error: ">
<!ENTITY serverError2.description ", ">
<!ENTITY wizard.title "Weave Setup">
<!ENTITY intro.title "Welcome to Weave">
<!ENTITY intro.description "[description of Weave]">
<!ENTITY intro-more.label "Learn more">
<!ENTITY intro-weave.description "Weave is an experimental prototype from Mozilla Labs that integrates online services with Firefox. ">
<!ENTITY intro-more.label "Learn more about the Weave project">
<!ENTITY intro-more.link "http://labs.mozilla.com">
<!ENTITY intro-warning.description "Warning: Use at your own risk! Backup Firefox data before continuing with installation.">
<!ENTITY welcome.title "Installation Type">
<!ENTITY curUser-title.label "Sign In">
<!ENTITY curUser.description "Sign into your existing account to set up Weave on this computer.">
<!ENTITY newUser-title.label "Get Started">
<!ENTITY newUser.description "Create a new account.">
<!ENTITY newUser.description "Create a new account and upload your Weave data to the server.">
<!ENTITY verify.title "Account Verification (Step 1 of 3)">
<!ENTITY username.label "User name:">
@ -42,7 +40,7 @@
<!ENTITY create3.title "Create Account (Step 3 of 5)">
<!ENTITY instanceName.description "Name this device... explain why... ">
<!ENTITY instanceName.description "Choose a name for this device for Weave">
<!ENTITY instanceName.label "Device name:">
<!ENTITY examples.label "Examples: &quot;Home computer&quot;, &quot;Mobile phone&quot;, &quot;Work laptop&quot;">
@ -62,7 +60,7 @@
<!ENTITY terms.label "Terms of Service">
<!ENTITY acceptTerms.label "I have read and accept the Terms of Service.">
<!ENTITY final.description "Your account will be created with the following preferences [this screen in progress]">
<!ENTITY final.description "Weave perform an initial synchronization with the following settings. Continue to the next wizard page to accept.">
<!ENTITY initialLogin.label "Signing you in.">
<!ENTITY initialPrefs.label "Setting your preferences.">
@ -73,7 +71,8 @@
<!ENTITY finalStep3Finished.label "Data synchronized.">
<!ENTITY thankyou.title "Thank you!">
<!ENTITY thankyou.description "You successfully installed Weave. etc... ">
<!ENTITY thankyou.description "Weave has been installed on this device and your data has been synchronized. To change your Weave preferences, use the Weave tab of your browser preferences. ">
<!ENTITY final-pref-title.description "Preferences"> <!ENTITY final-account-title.description "Account"> <!ENTITY final-sync-title.description "Initial Synchronization">
<!ENTITY userCheckFailed1.description "Our server is having problems and we couldn't check that username. ">
@ -87,3 +86,6 @@
<!ENTITY clickHere.text "Click here">
<!ENTITY tryAgain.text "Try again">
<!ENTITY serverError1.description "Server Error: ">
<!ENTITY serverError2.description ", ">

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

@ -40,7 +40,7 @@ create-success.label = Account for %S created.
final-pref-value.label = %S
final-account-value.label = Username: %S
final-sync-value.label = [Explain that a sync will happen]
final-sync-value.label = Weave will upload your data to the server.
final-success.label = Weave was successfully installed.
default-name.label = %S's Firefox

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

@ -192,6 +192,8 @@ Generator.prototype = {
this._exception = e;
} else if (e.message && e.message == 'Cannot acquire lock (internal lock)') {
this._log.warn("Exception: " + Utils.exceptionStr(e));
} else {
this._log.error("Exception: " + Utils.exceptionStr(e));
this._log.debug("Stack trace:\n" + Utils.stackTrace(e));

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

@ -252,9 +252,6 @@ DAVCollection.prototype = {
},
LOCK: function DC_LOCK(path, data, onComplete) {
if (!this._lockAllowed)
throw "Cannot acquire lock (internal lock)";
let headers = {'Content-type': 'text/xml; charset="utf-8"',
'Depth': 'infinity',
'Timeout': 'Second-600'};
@ -357,6 +354,9 @@ DAVCollection.prototype = {
let self = yield;
this._log.trace("Acquiring lock");
if (!this._lockAllowed)
throw {message: "Cannot acquire lock (internal lock)"};
this._lockAllowed = false;
if (DAVLocks['default']) {
this._log.debug("Lock called, but we already hold a token");
@ -372,8 +372,10 @@ DAVCollection.prototype = {
"</D:lockinfo>", self.cb);
let resp = yield;
if (resp.status < 200 || resp.status >= 300)
if (resp.status < 200 || resp.status >= 300) {
this._lockAllowed = true;
return;
}
let tokens = Utils.xpath(resp.responseXML, '//D:locktoken/D:href');
let token = tokens.iterateNext();
@ -386,11 +388,14 @@ DAVCollection.prototype = {
if (!DAVLocks['default']) {
this._log.warn("Could not acquire lock");
this._lockAllowed = true;
self.done();
return;
}
this._log.trace("Lock acquired");
this._lockAllowed = true;
self.done(DAVLocks['default']);
},

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

@ -203,7 +203,7 @@ let Utils = {
},
exceptionStr: function Weave_exceptionStr(e) {
let message = e.message? e.message : e;
let message = e.message ? e.message : e;
let location = "";
if (e.location)

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

@ -27,6 +27,7 @@ function FakeLoginManager(fakeLogins) {
Utils.getLoginManager = function fake_getLoginManager() {
// Return a fake nsILoginManager object.
return {
removeAllLogins: function() { self.fakeLogins = []; },
getAllLogins: function() { return self.fakeLogins; },
addLogin: function(login) {
getTestLogger().info("nsILoginManager.addLogin() called " +

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

@ -274,7 +274,7 @@ function FakeGUIDService() {
};
}
function SyncTestingInfrastructure() {
function SyncTestingInfrastructure(engineCtor) {
let __fakePasswords = {
'Mozilla Services Password': {foo: "bar"},
'Mozilla Services Encryption Passphrase': {foo: "passphrase"}
@ -289,6 +289,7 @@ function SyncTestingInfrastructure() {
};
Cu.import("resource://weave/identity.js");
Cu.import("resource://weave/util.js");
ID.set('WeaveID',
new Identity('Mozilla Services Encryption Passphrase', 'foo'));
@ -301,6 +302,45 @@ function SyncTestingInfrastructure() {
this.fakeFilesystem = new FakeFilesystemService({});
this.fakeGUIDService = new FakeGUIDService();
this._logger = getTestLogger();
this._Engine = engineCtor;
this._clientStates = [];
this.saveClientState = function pushClientState(label) {
let state = Utils.deepCopy(this.fakeFilesystem.fakeContents);
this._clientStates[label] = state;
};
this.restoreClientState = function restoreClientState(label) {
let state = this._clientStates[label];
function _restoreState() {
let self = yield;
this.fakeFilesystem.fakeContents = Utils.deepCopy(state);
let engine = new this._Engine();
engine._store.wipe();
let originalSnapshot = Utils.deepCopy(engine._store.wrap());
engine._snapshot.load();
let snapshot = engine._snapshot.data;
engine._core.detectUpdates(self.cb, originalSnapshot, snapshot);
let commands = yield;
engine._store.applyCommands.async(engine._store, self.cb, commands);
yield;
}
let self = this;
function restoreState(cb) {
_restoreState.async(self, cb);
}
this.runAsyncFunc("restore client state of " + label,
restoreState);
};
this.__makeCallback = function __makeCallback() {
this.__callbackCalled = false;
let self = this;
@ -310,7 +350,7 @@ function SyncTestingInfrastructure() {
};
this.runAsyncFunc = function runAsyncFunc(name, func) {
let logger = getTestLogger();
let logger = this._logger;
logger.info("-----------------------------------------");
logger.info("Step '" + name + "' starting.");
@ -324,4 +364,10 @@ function SyncTestingInfrastructure() {
do_check_eq(Async.outstandingGenerators.length, 0);
logger.info("Step '" + name + "' succeeded.");
};
this.resetClientState = function resetClientState() {
this.fakeFilesystem.fakeContents = {};
let engine = new this._Engine();
engine._store.wipe();
};
}

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

@ -15,7 +15,11 @@ function FakeMicrosummaryService() {
}
function run_test() {
var syncTesting = new SyncTestingInfrastructure();
// -----
// Setup
// -----
var syncTesting = new SyncTestingInfrastructure(BookmarksEngine);
function freshEngineSync(cb) {
let engine = new BookmarksEngine();
@ -23,47 +27,15 @@ function run_test() {
engine.sync(cb);
};
function resetProfile() {
syncTesting.fakeFilesystem.fakeContents = {};
let engine = new BookmarksEngine();
engine._store.wipe();
}
function saveClientState() {
return Utils.deepCopy(syncTesting.fakeFilesystem.fakeContents);
}
function restoreClientState(state, label) {
function _restoreState() {
let self = yield;
syncTesting.fakeFilesystem.fakeContents = Utils.deepCopy(state);
let engine = new BookmarksEngine();
engine._store.wipe();
let originalSnapshot = Utils.deepCopy(engine._store.wrap());
engine._snapshot.load();
let snapshot = engine._snapshot.data;
engine._core.detectUpdates(self.cb, originalSnapshot, snapshot);
let commands = yield;
engine._store.applyCommands.async(engine._store, self.cb, commands);
yield;
}
function restoreState(cb) {
_restoreState.async(this, cb);
}
syncTesting.runAsyncFunc("restore client state of " + label,
restoreState);
}
let bms = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
cleanUp();
// -----------
// Test Proper
// -----------
let boogleBm = bms.insertBookmark(bms.bookmarksMenuFolder,
uri("http://www.boogle.com"),
-1,
@ -89,9 +61,9 @@ function run_test() {
syncTesting.runAsyncFunc("swap bookmark order and re-sync",
freshEngineSync);
var firstComputerState = saveClientState();
syncTesting.saveClientState("first computer");
resetProfile();
syncTesting.resetClientState();
syncTesting.runAsyncFunc("re-sync on second computer", freshEngineSync);
@ -104,8 +76,12 @@ function run_test() {
syncTesting.runAsyncFunc("add bookmark on second computer and resync",
freshEngineSync);
restoreClientState(firstComputerState, "first computer");
syncTesting.restoreClientState("first computer");
syncTesting.runAsyncFunc("re-sync on first computer", freshEngineSync);
// --------
// Teardown
// --------
cleanUp();
}

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

@ -7,7 +7,7 @@ load("fake_login_manager.js");
// ----------------------------------------
function run_test() {
var syncTesting = new SyncTestingInfrastructure();
var syncTesting = new SyncTestingInfrastructure(PasswordEngine);
var fakeLoginManager = new FakeLoginManager(fakeSampleLogins);
function freshEngineSync(cb) {
@ -35,8 +35,7 @@ function run_test() {
syncTesting.runAsyncFunc("remove user and re-sync", freshEngineSync);
syncTesting.fakeFilesystem.fakeContents = {};
fakeLoginManager.fakeLogins = [];
syncTesting.resetClientState();
syncTesting.runAsyncFunc("resync on second computer", freshEngineSync);
}

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

@ -3,7 +3,7 @@ Testing INFO -----------------------------------------
Testing INFO Step 'initial sync' starting.
Testing INFO -----------------------------------------
Service.PasswordEngine INFO Beginning sync
Testing INFO HTTP MKCOL on user-data/passwords/
Testing INFO HTTP MKCOL on user-data/passwords/deltas
Service.RemoteStore DEBUG Downloading status file
Testing INFO HTTP GET from user-data/passwords/status.json, returning status 404
Service.PasswordEngine INFO Initial upload to server
@ -16,11 +16,6 @@ Service.Crypto DEBUG NOT encrypting data
Testing INFO HTTP PUT to user-data/passwords/snapshot.json with data: {"805ec58eb8dcded602999967e139be21acd0f194":{"hostname":"www.boogle.com","formSubmitURL":"http://www.boogle.com/search","httpRealm":"","username":"","password":"","usernameField":"test_person","passwordField":"test_password"}}
Service.Resource DEBUG PUT request successful
Service.JsonFilter DEBUG Encoding data as JSON
Service.CryptoFilter DEBUG Encrypting data
Service.Crypto DEBUG NOT encrypting data
Testing INFO HTTP PUT to user-data/passwords/deltas.json with data: []
Service.Resource DEBUG PUT request successful
Service.JsonFilter DEBUG Encoding data as JSON
Testing INFO HTTP PUT to user-data/passwords/status.json with data: {"GUID":"fake-guid-0","formatVersion":2,"snapVersion":0,"maxVersion":0,"snapEncryption":"none","deltasEncryption":"none","itemCount":1}
Service.Resource DEBUG PUT request successful
Service.RemoteStore INFO Full upload to server successful
@ -35,7 +30,7 @@ Testing INFO Opening 'weave/snapshots/passwords.json' for reading.
Testing INFO Reading from stream.
Service.SnapStore INFO Read saved snapshot from disk
Service.PasswordEngine INFO Beginning sync
Testing INFO HTTP MKCOL on user-data/passwords/
Testing INFO HTTP MKCOL on user-data/passwords/deltas
Service.RemoteStore DEBUG Downloading status file
Testing INFO HTTP GET from user-data/passwords/status.json, returning status 200
Service.Resource DEBUG GET request successful
@ -54,7 +49,7 @@ Testing INFO Opening 'weave/snapshots/passwords.json' for reading.
Testing INFO Reading from stream.
Service.SnapStore INFO Read saved snapshot from disk
Service.PasswordEngine INFO Beginning sync
Testing INFO HTTP MKCOL on user-data/passwords/
Testing INFO HTTP MKCOL on user-data/passwords/deltas
Service.RemoteStore DEBUG Downloading status file
Testing INFO HTTP GET from user-data/passwords/status.json, returning status 200
Service.Resource DEBUG GET request successful
@ -73,16 +68,11 @@ Service.PasswordEngine INFO Server conflicts: 0
Service.PasswordEngine INFO Actual changes for server: 1
Service.PasswordEngine DEBUG Actual changes for server: [{"action":"create","GUID":"1b3869fc36234b39cd354f661ed1d7d148394ca3","depth":0,"parents":[],"data":{"hostname":"www.yoogle.com","formSubmitURL":"http://www.yoogle.com/search","httpRealm":"","username":"","password":"","usernameField":"test_person2","passwordField":"test_password2"}}]
Service.PasswordEngine INFO Uploading changes to server
Testing INFO HTTP GET from user-data/passwords/deltas.json, returning status 200
Service.Resource DEBUG GET request successful
Service.CryptoFilter DEBUG Decrypting data
Service.Crypto DEBUG NOT decrypting data
Service.JsonFilter DEBUG Decoding JSON data
Service.JsonFilter DEBUG Encoding data as JSON
Service.CryptoFilter DEBUG Encrypting data
Service.Crypto DEBUG NOT encrypting data
Testing INFO HTTP PUT to user-data/passwords/deltas.json with data: [[{"action":"create","GUID":"1b3869fc36234b39cd354f661ed1d7d148394ca3","depth":0,"parents":[],"data":{"hostname":"www.yoogle.com","formSubmitURL":"http://www.yoogle.com/search","httpRealm":"","username":"","password":"","usernameField":"test_person2","passwordField":"test_password2"}}]]
Service.Resource DEBUG PUT request successful
Testing INFO HTTP PUT to user-data/passwords/deltas/1 with data: [{"action":"create","GUID":"1b3869fc36234b39cd354f661ed1d7d148394ca3","depth":0,"parents":[],"data":{"hostname":"www.yoogle.com","formSubmitURL":"http://www.yoogle.com/search","httpRealm":"","username":"","password":"","usernameField":"test_person2","passwordField":"test_password2"}}]
Service.ResourceSet DEBUG PUT request successful
Service.JsonFilter DEBUG Encoding data as JSON
Testing INFO HTTP PUT to user-data/passwords/status.json with data: {"GUID":"fake-guid-0","formatVersion":2,"snapVersion":0,"maxVersion":1,"snapEncryption":"none","deltasEncryption":"none","itemCount":2}
Service.Resource DEBUG PUT request successful
@ -99,7 +89,7 @@ Testing INFO Opening 'weave/snapshots/passwords.json' for reading.
Testing INFO Reading from stream.
Service.SnapStore INFO Read saved snapshot from disk
Service.PasswordEngine INFO Beginning sync
Testing INFO HTTP MKCOL on user-data/passwords/
Testing INFO HTTP MKCOL on user-data/passwords/deltas
Service.RemoteStore DEBUG Downloading status file
Testing INFO HTTP GET from user-data/passwords/status.json, returning status 200
Service.Resource DEBUG GET request successful
@ -118,16 +108,11 @@ Service.PasswordEngine INFO Server conflicts: 0
Service.PasswordEngine INFO Actual changes for server: 1
Service.PasswordEngine DEBUG Actual changes for server: [{"action":"remove","GUID":"1b3869fc36234b39cd354f661ed1d7d148394ca3","depth":0,"parents":[]}]
Service.PasswordEngine INFO Uploading changes to server
Testing INFO HTTP GET from user-data/passwords/deltas.json, returning status 200
Service.Resource DEBUG GET request successful
Service.CryptoFilter DEBUG Decrypting data
Service.Crypto DEBUG NOT decrypting data
Service.JsonFilter DEBUG Decoding JSON data
Service.JsonFilter DEBUG Encoding data as JSON
Service.CryptoFilter DEBUG Encrypting data
Service.Crypto DEBUG NOT encrypting data
Testing INFO HTTP PUT to user-data/passwords/deltas.json with data: [[{"action":"create","GUID":"1b3869fc36234b39cd354f661ed1d7d148394ca3","depth":0,"parents":[],"data":{"hostname":"www.yoogle.com","formSubmitURL":"http://www.yoogle.com/search","httpRealm":"","username":"","password":"","usernameField":"test_person2","passwordField":"test_password2"}}],[{"action":"remove","GUID":"1b3869fc36234b39cd354f661ed1d7d148394ca3","depth":0,"parents":[]}]]
Service.Resource DEBUG PUT request successful
Testing INFO HTTP PUT to user-data/passwords/deltas/2 with data: [{"action":"remove","GUID":"1b3869fc36234b39cd354f661ed1d7d148394ca3","depth":0,"parents":[]}]
Service.ResourceSet DEBUG PUT request successful
Service.JsonFilter DEBUG Encoding data as JSON
Testing INFO HTTP PUT to user-data/passwords/status.json with data: {"GUID":"fake-guid-0","formatVersion":2,"snapVersion":0,"maxVersion":2,"snapEncryption":"none","deltasEncryption":"none","itemCount":1}
Service.Resource DEBUG PUT request successful
@ -141,7 +126,7 @@ Testing INFO -----------------------------------------
Testing INFO Step 'resync on second computer' starting.
Testing INFO -----------------------------------------
Service.PasswordEngine INFO Beginning sync
Testing INFO HTTP MKCOL on user-data/passwords/
Testing INFO HTTP MKCOL on user-data/passwords/deltas
Service.RemoteStore DEBUG Downloading status file
Testing INFO HTTP GET from user-data/passwords/status.json, returning status 200
Service.Resource DEBUG GET request successful
@ -152,19 +137,22 @@ Service.PasswordEngine INFO Local snapshot version: -1
Service.PasswordEngine INFO Server maxVersion: 2
Service.RemoteStore TRACE Getting latest from snap --> scratch
Service.RemoteStore INFO Downloading all server data from scratch
Service.RemoteStore DEBUG Downloading server snapshot
Testing INFO HTTP GET from user-data/passwords/snapshot.json, returning status 200
Service.Resource DEBUG GET request successful
Service.CryptoFilter DEBUG Decrypting data
Service.Crypto DEBUG NOT decrypting data
Service.JsonFilter DEBUG Decoding JSON data
Service.RemoteStore DEBUG Downloading server deltas
Testing INFO HTTP GET from user-data/passwords/deltas.json, returning status 200
Service.Resource DEBUG GET request successful
Testing INFO HTTP GET from user-data/passwords/deltas/1, returning status 200
Service.ResourceSet DEBUG GET request successful
Service.CryptoFilter DEBUG Decrypting data
Service.Crypto DEBUG NOT decrypting data
Service.JsonFilter DEBUG Decoding JSON data
Service.SnapStore TRACE Processing command: {"action":"create","GUID":"1b3869fc36234b39cd354f661ed1d7d148394ca3","depth":0,"parents":[],"data":{"hostname":"www.yoogle.com","formSubmitURL":"http://www.yoogle.com/search","httpRealm":"","username":"","password":"","usernameField":"test_person2","passwordField":"test_password2"}}
Testing INFO HTTP GET from user-data/passwords/deltas/2, returning status 200
Service.ResourceSet DEBUG GET request successful
Service.CryptoFilter DEBUG Decrypting data
Service.Crypto DEBUG NOT decrypting data
Service.JsonFilter DEBUG Decoding JSON data
Service.SnapStore TRACE Processing command: {"action":"remove","GUID":"1b3869fc36234b39cd354f661ed1d7d148394ca3","depth":0,"parents":[]}
Service.PasswordEngine INFO Reconciling client/server updates
Service.PasswordSync DEBUG Reconciling 0 against 1 commands