Problem
On the Chrome extension pop-up page, using any JavaScript method that calls the pop-up, the pop-up animation is called, but as soon as the contents of the window are filled, the focus is instantly lost and disappears.
Itβs strange that the popup will remain open while the Chrome developer tools open in the context of the extension, but the popup will disappear immediately if the developer tools are closed.
This was happening on my old, confusing 2006 iMac, so I thought it was a problem with my configuration. However, I just did a fresh install of both Mac OS X (v1.7.5) and Chrome (v23.0.1271.97) on the 2007 iMac and created a very simple Chrome extension (code below) for testing and it still happens , I can not help but think that this is a bug with Chrome.
Code
"manifest.json"
{ "name": "Test Popups", "version": "0", "manifest_version": 2, "browser_action": { "default_popup": "popup.html" } }
"popup.html"
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="popup.js"></script> </head> <body> <input type="submit" id="btn_Alert" value="Alert" /> <input type="submit" id="btn_Confirm" value="Confirm" /> <input type="submit" id="btn_Prompt" value="Prompt" /> </body> </html>
"popup.js"
document.onreadystatechange = function(){ if (document.readyState === "complete"){ attach_eventListeners(); } } function attach_eventListeners(){ var btn_Alert = document.getElementById("btn_Alert"); var btn_Confirm = document.getElementById("btn_Confirm"); var btn_Prompt = document.getElementById("btn_Prompt"); btn_Alert.addEventListener("click", function(){ window.alert("Test"); }, false); btn_Confirm.addEventListener("click", function(){ window.confirm("Test"); }, false); btn_Prompt.addEventListener("click", function(){ window.prompt("Test", ""); }, false); }
Here is a link to the ZIP of these files . To test them yourself:
- Extract ZIP
- In Chrome, go to
chrome://chrome/extensions/ - Check "Developer Mode" in the upper right corner.
- Click "Download unpacked extension ..." in the upper left corner
- Select the folder containing the extracted files
- Click OK