Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/functional/confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ define([
var CONFIRM_URL = config.fxaContentRoot + 'confirm';
var SIGNUP_URL = config.fxaContentRoot + 'signup';

var closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;
var respondToWebChannelMessage = FunctionalHelpers.respondToWebChannelMessage;

registerSuite({
Expand Down Expand Up @@ -100,8 +101,7 @@ define([
.findByCssSelector('.google-header-bar')
.end()

.closeCurrentWindow()
.switchToWindow('')
.then(closeCurrentWindow())

.findByCssSelector('#fxa-confirm-header')
.end();
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/fx_fennec_v1_force_auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define([

var clearBrowserState = thenify(FunctionalHelpers.clearBrowserState);
var click = FunctionalHelpers.click;
var closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;
var createUser = FunctionalHelpers.createUser;
var fillOutForceAuth = FunctionalHelpers.fillOutForceAuth;
var noSuchBrowserNotification = FunctionalHelpers.noSuchBrowserNotification;
Expand Down Expand Up @@ -61,8 +62,7 @@ define([

// browser is notified of desire to open Sync preferences
.then(testIsBrowserNotified(this, 'fxaccounts:sync_preferences'))
.closeCurrentWindow()
.switchToWindow('')
.then(closeCurrentWindow())

.then(testElementExists('#fxa-sign-in-complete-header'))

Expand Down
7 changes: 3 additions & 4 deletions tests/functional/fx_fennec_v1_sign_in.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ define([

var clearBrowserState = thenify(FunctionalHelpers.clearBrowserState);
var click = FunctionalHelpers.click;
var closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;
var createUser = FunctionalHelpers.createUser;
var fillOutSignIn = thenify(FunctionalHelpers.fillOutSignIn);
var noSuchBrowserNotification = FunctionalHelpers.noSuchBrowserNotification;
Expand Down Expand Up @@ -61,8 +62,7 @@ define([

// browser is notified of desire to open Sync preferences
.then(testIsBrowserNotified(this, 'fxaccounts:sync_preferences'))
.closeCurrentWindow()
.switchToWindow('')
.then(closeCurrentWindow())

.then(testElementExists('#fxa-sign-in-complete-header'))

Expand Down Expand Up @@ -97,8 +97,7 @@ define([
.then(openVerificationLinkInNewTab(this, email, 1))
.switchToWindow('newwindow')
.then(testElementExists('#fxa-sign-up-complete-header'))
.closeCurrentWindow()
.switchToWindow('')
.then(closeCurrentWindow())

.then(testElementExists('#fxa-sign-up-complete-header'));
}
Expand Down
5 changes: 2 additions & 3 deletions tests/functional/fx_fennec_v1_sign_up.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define([
var email;
var PASSWORD = '12345678';

var closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;
var respondToWebChannelMessage = FunctionalHelpers.respondToWebChannelMessage;
var testEmailExpected = FunctionalHelpers.testEmailExpected;

Expand Down Expand Up @@ -122,9 +123,7 @@ define([
.then(FunctionalHelpers.testIsBrowserNotified(self, 'fxaccounts:sync_preferences'))


.closeCurrentWindow()
.switchToWindow('')
.end()
.then(closeCurrentWindow())

.findByCssSelector('#fxa-sign-up-complete-header')
.end()
Expand Down
7 changes: 3 additions & 4 deletions tests/functional/fx_firstrun_v1_sign_in.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ define([

var clearBrowserNotifications = FunctionalHelpers.clearBrowserNotifications;
var clearBrowserState = thenify(FunctionalHelpers.clearBrowserState);
var closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;
var createUser = FunctionalHelpers.createUser;
var fillOutSignIn = thenify(FunctionalHelpers.fillOutSignIn);
var noPageTransition = FunctionalHelpers.noPageTransition;
Expand Down Expand Up @@ -65,8 +66,7 @@ define([
.then(openVerificationLinkInNewTab(this, email, 0))
.switchToWindow('newwindow')
.then(testElementExists('#fxa-sign-in-complete-header'))
.closeCurrentWindow()
.switchToWindow('')
.then(closeCurrentWindow())

.then(testElementExists('#fxa-sign-in-complete-header'))
.then(noSuchBrowserNotification(this, 'fxaccounts:login'));
Expand Down Expand Up @@ -100,8 +100,7 @@ define([
.then(openVerificationLinkInNewTab(this, email, 1))
.switchToWindow('newwindow')
.then(testElementExists('#fxa-sign-up-complete-header'))
.closeCurrentWindow()
.switchToWindow('')
.then(closeCurrentWindow())

.then(testElementExists('#fxa-sign-up-complete-header'))
.then(noSuchBrowserNotification(this, 'fxaccounts:login'));
Expand Down
6 changes: 2 additions & 4 deletions tests/functional/fx_firstrun_v1_sign_up.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ define([
var email;
var PASSWORD = '12345678';

var closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;
var respondToWebChannelMessage = FunctionalHelpers.respondToWebChannelMessage;
var testEmailExpected = FunctionalHelpers.testEmailExpected;

Expand Down Expand Up @@ -84,11 +85,8 @@ define([
})

.end()
.closeCurrentWindow()

// switch back to the original window, it should transition.
.switchToWindow('')
.end()
.then(closeCurrentWindow())

.findByCssSelector('#fxa-sign-up-complete-header')
.end()
Expand Down
6 changes: 2 additions & 4 deletions tests/functional/fx_firstrun_v2_sign_up.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ define([
var email;
var PASSWORD = '12345678';

var closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;
var respondToWebChannelMessage = FunctionalHelpers.respondToWebChannelMessage;
var testEmailExpected = FunctionalHelpers.testEmailExpected;

Expand Down Expand Up @@ -119,11 +120,8 @@ define([
assert.equal(data.entryPoint, 'fxa:signup-complete');
}))

.closeCurrentWindow()

// switch back to the original window, it should transition.
.switchToWindow('')
.end()
.then(closeCurrentWindow())

.findByCssSelector('#fxa-sign-up-complete-header')
.end()
Expand Down
7 changes: 3 additions & 4 deletions tests/functional/fx_ios_v1_sign_in.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ define([
var thenify = FunctionalHelpers.thenify;

var clearBrowserState = thenify(FunctionalHelpers.clearBrowserState);
var closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;
var createUser = FunctionalHelpers.createUser;
var fillOutSignIn = thenify(FunctionalHelpers.fillOutSignIn);
var listenForFxaCommands = FxDesktopHelpers.listenForFxaCommands;
Expand Down Expand Up @@ -60,8 +61,7 @@ define([
.then(openVerificationLinkInNewTab(this, email, 0))
.switchToWindow('newwindow')
.then(testElementExists('#fxa-sign-in-complete-header'))
.closeCurrentWindow()
.switchToWindow('')
.then(closeCurrentWindow())

// about:accounts will take over post-verification, no transition
.then(noPageTransition('#fxa-confirm-signin-header'));
Expand All @@ -87,8 +87,7 @@ define([
.then(openVerificationLinkInNewTab(this, email, 1))
.switchToWindow('newwindow')
.then(testElementExists('#fxa-sign-up-complete-header'))
.closeCurrentWindow()
.switchToWindow('')
.then(closeCurrentWindow())

// about:accounts will take over post-verification, no transition
.then(noPageTransition('#fxa-confirm-header'));
Expand Down
5 changes: 2 additions & 3 deletions tests/functional/fx_ios_v1_sign_up.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ define([
var PASSWORD = '12345678';


var closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;
var listenForFxaCommands = FxDesktopHelpers.listenForFxaCommands;
var testEmailExpected = FunctionalHelpers.testEmailExpected;
var testIsBrowserNotifiedOfLogin = FxDesktopHelpers.testIsBrowserNotifiedOfLogin;
Expand Down Expand Up @@ -78,9 +79,7 @@ define([
})
.end()

.closeCurrentWindow()
.switchToWindow('')
.end()
.then(closeCurrentWindow())

.findByCssSelector('#fxa-confirm-header')
.end()
Expand Down
5 changes: 2 additions & 3 deletions tests/functional/fx_ios_v2_sign_up.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ define([
var email;
var PASSWORD = '12345678';

var closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;
var listenForFxaCommands = FxDesktopHelpers.listenForFxaCommands;
var testEmailExpected = FunctionalHelpers.testEmailExpected;

Expand Down Expand Up @@ -98,9 +99,7 @@ define([
})
.end()

.closeCurrentWindow()
.switchToWindow('')
.end()
.then(closeCurrentWindow())

.findByCssSelector('#fxa-confirm-header')
.end()
Expand Down
22 changes: 22 additions & 0 deletions tests/functional/lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,27 @@ define([
};
}

/**
* Close the current window and switch to the named tab. If
* The window will only be closed if it's not the last open window.
*
* @param {string} [tabName] - defaults to ''
* @returns {promise}
*/
function closeCurrentWindow(tabName) {
return function () {
return this.parent
.getAllWindowHandles()
.then(function (handles) {
if (handles.length > 1) {
return this.parent
.closeCurrentWindow()
.switchToWindow(tabName || '');
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shane-tomlinson should this throw if last window or no?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never thought of that.

});
};
}

/**
* Assert the value of an attribute
*
Expand Down Expand Up @@ -1411,6 +1432,7 @@ define([
clearBrowserState: clearBrowserState,
clearSessionStorage: clearSessionStorage,
click: click,
closeCurrentWindow: closeCurrentWindow,
createUser: createUser,
fetchAllMetrics: fetchAllMetrics,
fillOutChangePassword: fillOutChangePassword,
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/oauth_force_auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ define([
var thenify = FunctionalHelpers.thenify;

var clearBrowserState = thenify(FunctionalHelpers.clearBrowserState);
var closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;
var createUser = FunctionalHelpers.createUser;
var fillOutForceAuth = FunctionalHelpers.fillOutForceAuth;
var fillOutSignUp = thenify(FunctionalHelpers.fillOutSignUp);
Expand Down Expand Up @@ -76,8 +77,7 @@ define([
.then(testElementTextInclude('.account-ready-service', '123done'))

// switch to the original window
.closeCurrentWindow()
.switchToWindow('')
.then(closeCurrentWindow())

.then(testElementExists('#loggedin'))
// redirected back to the App
Expand Down
10 changes: 4 additions & 6 deletions tests/functional/oauth_permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ define([
var thenify = FunctionalHelpers.thenify;

var click = FunctionalHelpers.click;
var closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;
var createUser = FunctionalHelpers.createUser;
var fillOutForceAuth = FunctionalHelpers.fillOutForceAuth;
var fillOutSignIn = thenify(FunctionalHelpers.fillOutSignIn);
Expand Down Expand Up @@ -142,8 +143,7 @@ define([
.then(testElementTextInclude('.account-ready-service', '321done Untrusted'))

// switch to the original window
.closeCurrentWindow()
.switchToWindow('')
.then(closeCurrentWindow())

.then(testElementExists('#loggedin'));
},
Expand Down Expand Up @@ -194,8 +194,7 @@ define([
.then(testElementTextInclude('.account-ready-service', '321done Untrusted'))

// switch to the original window
.closeCurrentWindow()
.switchToWindow('')
.then(closeCurrentWindow())

.then(testElementExists('#loggedin'))
.then(click('#logout'))
Expand Down Expand Up @@ -251,8 +250,7 @@ define([
.then(click('#display-name button[type=submit]'))
.then(visibleByQSA('.settings-success'))

.closeCurrentWindow()
.switchToWindow('')
.then(closeCurrentWindow())

.then(click('.signin'))

Expand Down
9 changes: 4 additions & 5 deletions tests/functional/oauth_reset_password.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ define([
var email;
var client;

var closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;

registerSuite({
name: 'oauth reset password',

Expand Down Expand Up @@ -106,9 +108,7 @@ define([
})
.end()

.closeCurrentWindow()
// switch to the original window
.switchToWindow('')
.then(closeCurrentWindow())

// the original tab should automatically sign in
.findByCssSelector('#loggedin')
Expand Down Expand Up @@ -150,8 +150,7 @@ define([
.end()

// switch to the original window
.closeCurrentWindow()
.switchToWindow('');
.then(closeCurrentWindow());
},

'reset password, verify same browser by replacing the original tab': function () {
Expand Down
10 changes: 4 additions & 6 deletions tests/functional/oauth_sign_up.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ define([

var click = FunctionalHelpers.click;
var clearBrowserState = thenify(FunctionalHelpers.clearBrowserState);
var closeCurrentWindow = FunctionalHelpers.closeCurrentWindow;
var createUser = FunctionalHelpers.createUser;
var fillOutSignUp = thenify(FunctionalHelpers.fillOutSignUp);
var getVerificationLink = thenify(FunctionalHelpers.getVerificationLink);
Expand Down Expand Up @@ -101,8 +102,7 @@ define([
.end()

// switch to the original window
.closeCurrentWindow()
.switchToWindow('')
.then(closeCurrentWindow())

.findByCssSelector('#loggedin')
.end()
Expand Down Expand Up @@ -134,8 +134,7 @@ define([
.end()

// switch to the original window
.closeCurrentWindow()
.switchToWindow('');
.then(closeCurrentWindow());
},

'signup, verify same browser by replacing the original tab': function () {
Expand Down Expand Up @@ -316,8 +315,7 @@ define([
.end()

// switch to the original window
.closeCurrentWindow()
.switchToWindow('')
.then(closeCurrentWindow())

.findByCssSelector('#loggedin')
.end();
Expand Down
Loading