diff --git a/example/index.html b/example/index.html index 218584075f6923c2dcf1a81994315095f38a68a5..6c822dde4f7cacec015d2ebad3ced592181be7b3 100644 --- a/example/index.html +++ b/example/index.html @@ -102,7 +102,9 @@ function checkAssertion(assertion) { }); }; +$(document).ready(function() { // at page load time, we'll check to see if the user is already signed in +// for IE, this MUST be done after document ready. navigator.id.get(function(assertion) { if (!assertion) { $("#oPersistent").text("user isn't (persistently) signed in"); @@ -112,7 +114,6 @@ navigator.id.get(function(assertion) { }; }, { silent: true }); -$(document).ready(function() { // install a click handler for when the user clicks 'sign in' $("#clickForLogin").click(function(event) { event.preventDefault(); diff --git a/resources/static/communication_iframe/iframe.js b/resources/static/communication_iframe/iframe.js index 5869116c932ab883ff3c972b46328f0c5ab9b272..57e7080cd69f5425faec910c4901ba54dc2e3a25 100644 --- a/resources/static/communication_iframe/iframe.js +++ b/resources/static/communication_iframe/iframe.js @@ -61,7 +61,7 @@ function afterResourceLoad() { var chan = Channel.build({ window: window.parent, origin: "*", - scope: "mozid" + scope: "mozid_ni" }); var remoteOrigin = undefined; @@ -79,7 +79,6 @@ function afterResourceLoad() { trans.delayReturn(true); BrowserID.User.getPersistentSigninAssertion(function(rv) { - console.log(rv); trans.complete(rv); }, function() { trans.error(); diff --git a/resources/static/include.js b/resources/static/include.js index 5366ba8d9903ecf515102fbb23070d8ece4e8c20..3fb15233716286dad61c72ae74603f78c9fe3872 100644 --- a/resources/static/include.js +++ b/resources/static/include.js @@ -716,22 +716,20 @@ var ipServer = "https://browserid.org"; var isFennec = navigator.userAgent.indexOf('Fennec/') != -1; - var chan, w, iframe; + var relay_chan, w, relay_iframe; // keep track of these so that we can re-use/re-focus an already open window. navigator.id.get = function(callback, options) { + var doc = document; function cleanup() { - chan.destroy(); - chan = null; + // we no longer remove the relay chan and iframe + // since those live for as long as the page does if (w) { w.close(); w = null; } - iframe.parentNode.removeChild(iframe); - iframe = null; - _detatch_event(window, 'unload', cleanup); } @@ -755,22 +753,9 @@ return; } - var frameid = _get_relayframe_id(); - var iframe = _open_relayframe("browserid_relay_" + frameid); - - // first we build the channel to the IFRAME - // and make the call. THEN we will open the window - // no need to wait for channel ready. - - // clean up a previous channel that never was reaped - if (chan) chan.destroy(); - chan = Channel.build({ - window: iframe.contentWindow, - origin: ipServer, - scope: "mozid" - }); - - chan.call({ + // we now have the relay iframe and channel already + // we just message it. + relay_chan.call({ method: "getVerifiedEmail", success: function(rv) { if (callback) { @@ -811,16 +796,14 @@ var _noninteractiveCall = function(method, args, onsuccess, onerror) { var doc = window.document; - iframe = _open_hidden_iframe(doc); + var ni_iframe = _open_hidden_iframe(doc); - // clean up channel - if (chan) chan.destroy(); - chan = Channel.build({window: iframe.contentWindow, origin: ipServer, scope: "mozid"}); + var chan = Channel.build({window: ni_iframe.contentWindow, origin: ipServer, scope: "mozid_ni"}); function cleanup() { chan.destroy(); chan = undefined; - doc.body.removeChild(iframe); + doc.body.removeChild(ni_iframe); } chan.call({ @@ -837,7 +820,25 @@ cleanup(); } }); - } + }; + + // set up the relay iframe + var setup_relay_iframe = function() { + if (document.body) { + var frameid = _get_relayframe_id(); + relay_iframe = _open_relayframe("browserid_relay_" + frameid); + relay_chan = Channel.build({ + window: relay_iframe.contentWindow, + origin: ipServer, + scope: "mozid" + }); + + } else { + window.setTimeout(setup_relay_iframe, 100); + } + }; + + window.setTimeout(setup_relay_iframe, 0); navigator.id._getVerifiedEmailIsShimmed = true; }