diff --git a/bin/load_gen b/bin/load_gen index 5133533408df5bfdbbfa245cd47de825d526cf9b..5eb1ea00b2d4b9b70a8c4c4e30fc0ad9bd74ba62 100755 --- a/bin/load_gen +++ b/bin/load_gen @@ -58,8 +58,11 @@ var argv = require('optimist') .describe('o', 'when enabled, only dynamic WSAPI calls will be simulated, not static resource requests') .default('o', false) .alias('s', 'server') +.string('s') .describe('s', 'base URL to browserid server') -.demand('s') +.check(function(argv) { + return (typeof argv.s === 'string' || argv.l) != undefined; +}) .alias('v', 'verifier') .describe('v', 'base URL to verifier service (default is browserid server + \'/verify\')') .alias('u', 'user-range') @@ -67,11 +70,6 @@ var argv = require('optimist') var args = argv.argv; -if (args.h) { - argv.showHelp(); - process.exit(1); -} - // global configuration const configuration = { verifier: args.v ? args.v : args.s + "/verify", @@ -139,6 +137,11 @@ if (args.l) { process.exit(0); } +if (args.h) { + argv.showHelp(); + process.exit(1); +} + var activitiesToRun = Object.keys(activity); // handle modification of activities to run (-o or -a) diff --git a/resources/static/dialog/controllers/dialog.js b/resources/static/dialog/controllers/dialog.js index e570e4e716161abd223eb6c3eb3d8c01dcd9a8c7..0cc46aab5a3dadfbe852c2ddf458b2550815fc89 100644 --- a/resources/static/dialog/controllers/dialog.js +++ b/resources/static/dialog/controllers/dialog.js @@ -74,6 +74,18 @@ BrowserID.Modules.Dialog = (function() { function startChannel() { var self = this; + // first, we see if there is a local channel + if (win.navigator.id && win.navigator.id.channel) { + win.navigator.id.channel.registerController(self); + return; + } + + // next, we see if the caller intends to call native APIs + if (win.location.hash == "#NATIVE" || win.location.hash == "#INTERNAL") { + // don't do winchan, let it be. + return; + } + try { // WinChan.onOpen(function(origin, args, cb) { diff --git a/resources/static/test/qunit/controllers/dialog_unit_test.js b/resources/static/test/qunit/controllers/dialog_unit_test.js index d2d04bee3e2daae284b555a8c4d27f7d55f7eb41..dca71d36cd654fd4ca96a8f60cf613d54ed8f6b5 100644 --- a/resources/static/test/qunit/controllers/dialog_unit_test.js +++ b/resources/static/test/qunit/controllers/dialog_unit_test.js @@ -72,10 +72,10 @@ }, location: { - } - + }, - } + navigator: {}, + }; function createController(config) { var config = $.extend({ @@ -116,6 +116,49 @@ }); }); + asyncTest("initialization with add-on navigator.id.channel", function() { + var ok_p = false; + + // expect registerController to be called. + winMock.navigator.id = { + channel : { + registerController: function(controller) { + ok_p = controller.getVerifiedEmail && controller.get; + } + } + }; + + createController({ + ready: function() { + ok(ok_p, "registerController was not called with proper controller"); + start(); + } + }); + }); + + asyncTest("initialization with #NATIVE", function() { + winMock.location.hash = "#NATIVE"; + + createController({ + ready: function() { + ok($("#error .contents").text().length == 0, "no error should be reported"); + start(); + } + }); + }); + + + asyncTest("initialization with #INTERNAL", function() { + winMock.location.hash = "#INTERNAL"; + + createController({ + ready: function() { + ok($("#error .contents").text().length == 0, "no error should be reported"); + start(); + } + }); + }); + /* test("doXHRError while online, no network info given", function() { createController(); diff --git a/tests/password-update-test.js b/tests/password-update-test.js index 9e22cbc1b5cbd36a05d45b42cc0ae62460d483ae..c42c4d0cbfd87dac5e6b353eb7a70630b10cbf12 100755 --- a/tests/password-update-test.js +++ b/tests/password-update-test.js @@ -122,6 +122,18 @@ suite.addBatch({ } }); +suite.addBatch({ + "updating the password without specifying a proper old password": { + topic: wsapi.post('/wsapi/update_password', { + oldpass: "bogus ass password", + newpass: NEW_PASSWORD + }), + "fails as expected": function(r, err) { + assert.strictEqual(JSON.parse(r.body).success, false); + } + } +}); + suite.addBatch({ "updating the password": { topic: wsapi.post('/wsapi/update_password', {