forked from rnewman/services-central-old
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 601973 - SyncEngine._testDecrypt() yields wrong result [r=mconnor]
Fix a 'this' scoping error in SyncEngine._testDecrypt(). Rename this method to canDecrypt() since it's clearly public API. Provide tests for SyncEngine.canDecrypt() as well as Service.wipeClient().
- Loading branch information
Showing
4 changed files
with
132 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
Cu.import("resource://services-sync/service.js"); | ||
Cu.import("resource://services-sync/engines.js"); | ||
|
||
|
||
function CanDecryptEngine() { | ||
SyncEngine.call(this, "CanDecrypt"); | ||
} | ||
CanDecryptEngine.prototype = { | ||
__proto__: SyncEngine.prototype, | ||
|
||
// Override these methods with mocks for the test | ||
canDecrypt: function canDecrypt() { | ||
return true; | ||
}, | ||
|
||
wasWiped: false, | ||
wipeClient: function wipeClient() { | ||
this.wasWiped = true; | ||
} | ||
}; | ||
Engines.register(CanDecryptEngine); | ||
|
||
|
||
function CannotDecryptEngine() { | ||
SyncEngine.call(this, "CannotDecrypt"); | ||
} | ||
CannotDecryptEngine.prototype = { | ||
__proto__: SyncEngine.prototype, | ||
|
||
// Override these methods with mocks for the test | ||
canDecrypt: function canDecrypt() { | ||
return false; | ||
}, | ||
|
||
wasWiped: false, | ||
wipeClient: function wipeClient() { | ||
this.wasWiped = true; | ||
} | ||
}; | ||
Engines.register(CannotDecryptEngine); | ||
|
||
|
||
function test_withEngineList() { | ||
try { | ||
_("Ensure initial scenario."); | ||
do_check_false(Engines.get("candecrypt").wasWiped); | ||
do_check_false(Engines.get("cannotdecrypt").wasWiped); | ||
|
||
_("Wipe local engine data."); | ||
Service.wipeClient(["candecrypt", "cannotdecrypt"]); | ||
|
||
_("Ensure only the engine that can decrypt was wiped."); | ||
do_check_true(Engines.get("candecrypt").wasWiped); | ||
do_check_false(Engines.get("cannotdecrypt").wasWiped); | ||
} finally { | ||
Engines.get("candecrypt").wasWiped = false; | ||
Engines.get("cannotdecrypt").wasWiped = false; | ||
Service.startOver(); | ||
} | ||
} | ||
|
||
function run_test() { | ||
test_withEngineList(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters