Index: chrome/test/data/login/saml_api_login_v2.html |
diff --git a/chrome/test/data/login/saml_api_login.html b/chrome/test/data/login/saml_api_login_v2.html |
similarity index 55% |
rename from chrome/test/data/login/saml_api_login.html |
rename to chrome/test/data/login/saml_api_login_v2.html |
index 54055edfbcb83aa1266ee335a88941b517d72b3b..118638ea8fcae20a03b4bb7047aec1f4e3580114 100644 |
--- a/chrome/test/data/login/saml_api_login.html |
+++ b/chrome/test/data/login/saml_api_login_v2.html |
@@ -1,15 +1,36 @@ |
<html> |
<head> |
<script type="text/javascript"> |
+ var initialized = false; |
+ var sendAndSumitRequested = false; |
+ |
function initialize() { |
+ window.addEventListener('message', function(event) { |
+ if (!event.data || event.data.type != 'gaia_saml_api_reply') |
+ return; |
+ var response = event.data.response; |
+ if (response.result != 'initialized' || |
+ response.version != 2 || |
+ response.keyTypes.indexOf('KEY_TYPE_PASSWORD_PLAIN') == -1) { |
+ return; |
+ } |
+ initialized = true; |
+ if (sendAndSumitRequested) |
+ send_and_submit(); |
+ }); |
+ |
window.setTimeout(function() { |
window.postMessage({ |
type: 'gaia_saml_api', |
- call: {method: 'initialize'}}, '/'); |
+ call: {method: 'initialize', requestedVersion: 2}}, '/'); |
}, 0); |
} |
function send_and_submit() { |
+ if (!initialized) { |
+ sendAndSumitRequested = true; |
+ return; |
+ } |
var form = document.forms[0]; |
var token = form.elements['RelayState'].value; |
var user = form.elements['Email'].value; |
@@ -20,7 +41,8 @@ |
call: {method: 'add', |
token: token, |
user: user, |
- password: password}}, '/'); |
+ passwordBytes: password, |
+ keyType: 'KEY_TYPE_PASSWORD_PLAIN'}}, '/'); |
form.submit(); |
}, 0); |
} |