Created
November 13, 2012 23:41
-
-
Save jrgm/4069186 to your computer and use it in GitHub Desktop.
If you visit login.dev.persona.org first, there is no Aw, snap!
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
#!/usr/bin/env node | |
/* This Source Code Form is subject to the terms of the Mozilla Public | |
* License, v. 2.0. If a copy of the MPL was not distributed with this | |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
// | |
// Two switches to control how this runs: | |
// 1) VISIT_PERSONA=1 - Load the login.dev.anosrep.org first | |
// 2) REUSE_BROWSER=1 - If set, don't get a new browser for | |
// each attempt to 'Aw, snap!'. | |
// So, seems to be an issue with pre-initializing something | |
// from the main site (network URLs, cookies, or, hmm, | |
// localStorage?. Others) | |
// | |
const | |
path = require('path'), | |
assert = require('../lib/asserts.js'), | |
restmail = require('../lib/restmail.js'), | |
utils = require('../lib/utils.js'), | |
persona_urls = require('../lib/urls.js'), | |
CSS = require('../pages/css.js'), | |
dialog = require('../pages/dialog.js'), | |
testSetup = require('../lib/test-setup.js'), | |
runner = require('../lib/runner.js'), | |
secrets = require('../../lib/secrets.js'); | |
var browser; | |
var count = 0; | |
var init = { | |
"setup": function(done) { | |
testSetup.setup({b:1}, function(err, fix) { | |
browser = fix.b[0]; | |
done(err); | |
}); | |
}, | |
"startup browser": function(done) { | |
testSetup.newBrowserSession(browser, done); | |
}, | |
}; | |
var awsnap = { | |
"create a new window/tab": function(done) { | |
browser.newWindow('about:blank', '__hack' + count++, done); | |
}, | |
"close current and switch to new window": function(done) { | |
browser.chain({onError: done}) | |
.close() | |
.wwin(done); | |
}, | |
"go to persona?": function(done) { | |
var url = process.env.VISIT_PERSONA ? persona_urls['persona'] : 'about:blank'; | |
browser.get(url, done); | |
}, | |
"go to 123done, click sign in": function(done) { | |
browser.chain({onError: done}) | |
.get(persona_urls['123done']) | |
.wclick(CSS['123done.org'].signinButton, done); | |
}, | |
"switch to the persona dialog": function(done) { | |
browser.wwin(CSS['persona.org'].windowName, done); | |
}, | |
"go through signup flow": function(done) { | |
dialog.signInAsNewUser({ | |
browser: browser, | |
email: secrets.weakGenerate(16) + '@mozilla.com', | |
password: secrets.weakGenerate(8), | |
}, done); | |
}, | |
// Since the correct DOM is there, don't know how to assert whether this | |
// passed or failed. Just visually inspect for this hack. | |
"switch to the main window": function(done) { | |
browser.chain({onError: done}) | |
.wwin() | |
.delay(1000) | |
.get(persona_urls['persona']) | |
.delay(5000, done); | |
}, | |
}; | |
var finis = { | |
"terminate session": function(done) { | |
browser.quit(done); | |
}, | |
}; | |
var iterations = 5; | |
// [ init, awsnap, awsnap, ... ] | |
var reuseSequence = [ init ]; | |
for (var i = 0; i < iterations; ++i) { | |
reuseSequence.push(awsnap); | |
} | |
reuseSequence.push(finis); | |
// [ init, awsnap, finis, init, awsnap, finis, ... ] | |
var reinitSequence = []; | |
for (var j = 0; j < iterations; ++j) { | |
reinitSequence = reinitSequence.concat([ init, awsnap, finis ]); | |
} | |
runner.run( | |
module, | |
process.env.REUSE_BROWSER ? reuseSequence : reinitSequence, | |
{ | |
suiteName: path.basename(__filename), | |
cleanup: function(done) { testSetup.teardown(done); } | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment