diff options
author | dpolukhin <dpolukhin@chromium.org> | 2015-04-08 05:59:37 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-08 13:00:19 +0000 |
commit | e29cf14a9baa835b86f199f38bc1ac8db1feab5a (patch) | |
tree | 0f823fb48b49512b361900585499d541109500a3 /google_apis/test/embedded_setup_chromeos.html | |
parent | 06cf7258babe8e44b904d36ac9beb9a954e985e4 (diff) | |
download | chromium_src-e29cf14a9baa835b86f199f38bc1ac8db1feab5a.zip chromium_src-e29cf14a9baa835b86f199f38bc1ac8db1feab5a.tar.gz chromium_src-e29cf14a9baa835b86f199f38bc1ac8db1feab5a.tar.bz2 |
Basic tests for new webview based signin flow
Extract common code for all login test from SamlTest.
Separate HTML for /embedded/setup/chromeos in fake_gaia.
Updated SAML test to use new GAIA endpoint in webview cases.
BUG=472095
TEST=browser_tests
Review URL: https://codereview.chromium.org/1054403002
Cr-Commit-Position: refs/heads/master@{#324221}
Diffstat (limited to 'google_apis/test/embedded_setup_chromeos.html')
-rw-r--r-- | google_apis/test/embedded_setup_chromeos.html | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/google_apis/test/embedded_setup_chromeos.html b/google_apis/test/embedded_setup_chromeos.html new file mode 100644 index 0000000..d2175f0 --- /dev/null +++ b/google_apis/test/embedded_setup_chromeos.html @@ -0,0 +1,110 @@ +<html> +<head> +<script> +var gaia = gaia || {}; +gaia.chromeOSLogin = {}; + +gaia.chromeOSLogin.parent_webview_signin_url_ = 'chrome://chrome-signin'; +gaia.chromeOSLogin.parent_webview_oob_url_ = 'chrome://oobe'; +gaia.chromeOSLogin.parent_webview_ = undefined; +gaia.chromeOSLogin.parent_webview_url_ = undefined; + +gaia.chromeOSLogin.registerHtml5Listener = function() { + var onMessage = function(e) { + if (e.origin == gaia.chromeOSLogin.parent_webview_signin_url_ || + e.origin == gaia.chromeOSLogin.parent_webview_oob_url_) { + gaia.chromeOSLogin.parent_webview_ = e.source; + gaia.chromeOSLogin.parent_webview_url_ = e.origin; + + // Repeat clearOldAttempts as soon as we got parent. + gaia.chromeOSLogin.clearOldAttempts(); + } + }; + window.addEventListener('message', onMessage); +} + +gaia.chromeOSLogin.clearOldAttempts = function() { + var msg = { + 'method': 'clearOldAttempts' + }; + gaia.chromeOSLogin.parent_webview_.postMessage(msg, + gaia.chromeOSLogin.parent_webview_url_); +}; + +gaia.chromeOSLogin.attemptLogin = function(email, password) { + var msg = { + 'method': 'attemptLogin', + 'email': email, + 'password': password, + }; + gaia.chromeOSLogin.parent_webview_.postMessage(msg, + gaia.chromeOSLogin.parent_webview_url_); +}; + +gaia.chromeOSLogin.backButton = function(show) { + var msg = { + 'method': 'backButton', + 'show': show, + }; + gaia.chromeOSLogin.parent_webview_.postMessage(msg, + gaia.chromeOSLogin.parent_webview_url_); +}; + +function goNext() { + if (!document.getElementById("page1").hidden) { + document.getElementById("page1").hidden = true; + document.getElementById("page2").hidden = false; + history.pushState({}, "", window.location.pathname + "#challengepassword"); + + request = new XMLHttpRequest(); + request.open('POST', '/_/embedded/lookup/accountlookup', true); + request.onreadystatechange = function() { + if (request.readyState == 4 && request.status == 200) { + if (request.getResponseHeader("continue")) + location.assign(request.getResponseHeader("continue")); + } + }; + var email = document.getElementById("identifier").value; + request.send('identifier=' + encodeURIComponent(email)); + + gaia.chromeOSLogin.attemptLogin(email, ""); + gaia.chromeOSLogin.backButton(true); + } else if (!document.getElementById("page2").hidden) { + var email = document.getElementById("identifier").value; + var password = document.getElementById("password").value; + + request = new XMLHttpRequest(); + request.open('POST', '/_/embedded/signin/challenge', true); + request.onreadystatechange = function() { + if (request.readyState == 4 && request.status == 200) { + history.pushState({}, "", window.location.pathname + "#close"); + } + }; + request.send('identifier=' + encodeURIComponent(email)); + + gaia.chromeOSLogin.attemptLogin(email, password); + } +} + +function onLoad() { + gaia.chromeOSLogin.registerHtml5Listener(); + document.getElementById("page1").hidden = false; + history.replaceState({}, "", window.location.pathname + "#identifier"); + gaia.chromeOSLogin.clearOldAttempts(); +} + +</script> +</head> +<body onload='onLoad();'> + Local Auth Server:<br> + <div id="page1" hidden> + Email + <input id="identifier" name="identifier" type="email" spellcheck="false" autocomplete="off" formnovalidate=""> + </div> + <div id="page2" hidden> + Password + <input id="password" name="password" type="password" spellcheck="false" autocomplete="off" formnovalidate=""> + </div><br> + <div id='nextButton' onclick='goNext();'>Next</div> +</body> +</html> |