adobe/brackets — pull request #4357 by jasonsanjose (2013-06-26 19:45:15+00:00)
Title: When relaunching chrome, only restart connection workflow at interstitial page load

This looks worse that it really is, promise! :smiley:

I factored out several inline functions (to satisfy JSLint's function ordering). The main change is on line 843 where previously we called ``open()`` we now call ``_openInterstitialPage()``.

The symptom in the bug was due to calling ``loadAgents()`` twice. We never uninstalled the ``_onConnect`` handler when we relaunched chrome. So, instead of restarting the entire open workflow when we know we're going to relaunch, we just close and reopen the browser (now with debugging enabled) then open the interstitial page again.

Note that on mac we still have the problem where the failed interstitial page tab is still open. Meaning, we get one tab with the correct live preview page and a 2nd tab with the interstitial page that will remain open, is harmless, but still slightly confusing. Unfortunately, we can't programatically close this extra page without a more invasive fix, either:

* Set a timeout in the interstitial page to close after some time. This may be jarring depending on if it happens before or after relaunch
* Change the connection workflow to search for duplicate interstitial tabs