From 592706f2e414a69b9671f43c3f4efc86f89f7c01 Mon Sep 17 00:00:00 2001 From: Ben Adida <ben@adida.net> Date: Thu, 10 Nov 2011 14:42:21 -0800 Subject: [PATCH] changed passing of relayframe id via localstorage so more can be done in the page before window.open --- resources/static/dialog/resources/channel.js | 4 +--- resources/static/include.js | 24 +++++++++----------- resources/static/relay/relay.js | 2 ++ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/resources/static/dialog/resources/channel.js b/resources/static/dialog/resources/channel.js index 859d641b8..04cdd2b78 100644 --- a/resources/static/dialog/resources/channel.js +++ b/resources/static/dialog/resources/channel.js @@ -57,8 +57,7 @@ onCompleteCallback; function getRelayName() { - var relayID = win.location.href.slice(win.location.href.indexOf('#') + 1); - return "browserid_relay_" + relayID; + return window.localStorage.RELAYFRAME_NAME; } function getRelayWindow() { @@ -91,7 +90,6 @@ onCompleteCallback = onComplete; controller.getVerifiedEmail(origin, onsuccess, onerror); }); - win.location.hash = ''; } else { throw "relay frame not found"; diff --git a/resources/static/include.js b/resources/static/include.js index d9d07938c..5366ba8d9 100644 --- a/resources/static/include.js +++ b/resources/static/include.js @@ -757,25 +757,17 @@ var frameid = _get_relayframe_id(); var iframe = _open_relayframe("browserid_relay_" + frameid); - w = _open_window(); - - // if the RP window closes, close the dialog as well. - _attach_event(window, 'unload', cleanup); + // 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", - onReady: function() { - // We have to change the name of the relay frame every time or else Firefox - // has a problem re-attaching new iframes with the same name. Code inside - // of frames with the same name sometimes does not get run. - // See https://bugzilla.mozilla.org/show_bug.cgi?id=350023 - //w = _open_window(ipServer + "/sign_in#" + frameid); - w.location = ipServer + "/sign_in#" +frameid; - } + scope: "mozid" }); chan.call({ @@ -793,6 +785,12 @@ cleanup(); } }); + + // open the window now that all else is ready + w = _open_window(ipServer + "/sign_in"); + + // if the RP window closes, close the dialog as well. + _attach_event(window, 'unload', cleanup); } }; diff --git a/resources/static/relay/relay.js b/resources/static/relay/relay.js index d9c86f4c1..d919aa8ff 100644 --- a/resources/static/relay/relay.js +++ b/resources/static/relay/relay.js @@ -39,6 +39,8 @@ (function() { "use strict"; + window.localStorage.RELAYFRAME_NAME = window.name; + window.console = window.console || { log: function() {} }; -- GitLab