Closed Bug 291261 Opened 20 years ago Closed 16 years ago

window.open().close(); causes an exception

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 310955

People

(Reporter: sync2d, Unassigned)

References

()

Details

User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Build Identifier: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3

Closing a newly opened window immediately after opening it causes an exception.

Reproducible: Always

Steps to Reproduce:
1. navigate the browser to javascript:open().close();
Actual Results:  
The following message will be shown in the JavaScript Console.

Error: uncaught exception: [Exception... "Component returned failure code: 
0x80004005 (NS_ERROR_FAILURE) [nsIDOMXULElement.boxObject]"  
nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: 
chrome://global/content/bindings/browser.xml :: get_docShell :: line 0"  data: 
no]

Expected Results:  
Complete the operation without exceptions.

Workaround:
var w=open();setTimeout(function(){w.close();}, 0);
I don't get that error message it get this Erreur : open() has no properties
Fichier Source : javascript:open().close();
Ligne : 1 using Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-FR; rv:1.7.7)
Gecko/20050414 Firefox/1.0.3
Component: Tabbed Browser → JavaScript Engine
Product: Firefox → Core
Version: unspecified → 1.7 Branch
Assignee: bugs → general
QA Contact: tabbed-browser → general
I get the same thing with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8b2) Gecko/20050420 Firefox/1.0+
Please use the right component when reporting DOM bugs.

/be
Assignee: general → general
Component: JavaScript Engine → DOM: Level 0
I chose "Tabbed Browser" component when reporting the bug because
the exception occurred in chrome://global/content/bindings/browser.xml.
And today, I discovered that the behavior of the testcase
depends on Firefox's built-in single window mode feature.
So I think "Firefox" product and "Tabbed Browser"
component are right choices.

---------- New test results ----------

[[text]] denotes an entry in [Tools -> Options... -> Advanced].

1. When [[Force links that open new window to open in]] is unchecked:
I get the following messages in the JavaScript Console.

Error: uncaught exception: [Exception... "Component returned failure code: 
0x80004005 (NS_ERROR_FAILURE) [nsIControllers.removeController]"  
nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: 
chrome://browser/content/search.xml :: onxbldestructor :: line 77"  data: no]
Error: uncaught exception: [Exception... "Component returned failure code: 
0x80004005 (NS_ERROR_FAILURE) [nsIObserverService.removeObserver]"  
nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: 
chrome://mozapps/content/update/updates.xml :: onxbldestructor :: line 20"  
data: no]
Error: uncaught exception: [Exception... "Component returned failure code: 
0x80004005 (NS_ERROR_FAILURE) [nsIObserverService.removeObserver]"  
nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: 
chrome://browser/content/browser.js :: Shutdown :: line 831"  data: no]

2. When [[the same tab/window as the link]] is selected:
2.a. in the first window:
  The current browser window closes immediately.
2.b. in the second window opened by [File -> New Window]:
  "Scripts may not close windows that were not opened by script."
  in the JavaScript Console.

3. When [[a new tab]] is selected:
I get the following messages in the JavaScript Console.

Error: uncaught exception: [Exception... "Component returned failure code: 
0x80004005 (NS_ERROR_FAILURE) [nsIDOMXULElement.boxObject]"  
nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: 
chrome://global/content/bindings/browser.xml :: get_docShell :: line 0"  data: 
no]
shutdown, I was not addressing you; it was gmcbugzilla who changed component. 
No big deal in any event, but I wanted to point this bug toward the DOM Level 0
component, since that's where bugs involving window.open and .close belong.  If
the tabbrowser widget in Firefox's toolkit has some role in this bug, I won't be
surprised, but at the end of the day the DOM level 0 is where the buck stops for
window.* methods.

Can someone please confirm this bug?

/be
Confirming on WinXPSP2 for Firefox/Mozilla on 1.7.7 and trunk. Looks like
observers and controllers are the culprits. Not sure where this should live though.

Firefox 1.0.3
Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIObserverService.removeObserver]"  nsresult:
"0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame ::
chrome://mozapps/content/update/updates.xml :: onxbldestructor :: line 20" 
data: no]

Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIControllers.removeController]"  nsresult:
"0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame ::
chrome://browser/content/search.xml :: onxbldestructor :: line 77"  data: no]

Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIObserverService.removeObserver]"  nsresult:
"0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame ::
chrome://browser/content/browser.js :: Shutdown :: line 831"  data: no]

Firefox 1.1+
Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIControllers.removeController]"  nsresult:
"0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame ::
chrome://browser/content/search.xml ::  :: line 77"  data: no]

Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIObserverService.removeObserver]"  nsresult:
"0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame ::
chrome://mozapps/content/update/updates.xml ::  :: line 20"  data: no]

Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIObserverService.removeObserver]"  nsresult:
"0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame ::
chrome://browser/content/browser.js :: BrowserShutdown :: line 824"  data: no]


Mozilla 1.7.7
Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIControllers.removeController]"  nsresult:
"0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame ::
chrome://navigator/content/navigator.js :: Shutdown :: line 742"  data: no]

"Mozilla" 1.8b2
Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIControllers.removeController]"  nsresult:
"0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame ::
chrome://navigator/content/navigator.js :: Shutdown :: line 806"  data: no]
Status: UNCONFIRMED → NEW
Ever confirmed: true
So I'm guessing the problem is that we're effectively closing the window before
the XUL onload has fired.  If so, there's nothing wrong with that, per se; I
think the chrome could should just be fixed to deal with it...
I don't see any errors from my trunk build.
I tried open().close() in the JS console, and also javascript:open().close() in
the browser with and without new windows forced into tabs.
(In reply to comment #8)
I still see them in firefox and seamonkey trunk builds on winxp from today.
obligatory update. the bug is still present in:
Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.9) Gecko/20050709 Firefox/1.0.5
Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8b3) Gecko/20050708 Firefox/1.0+
Blocks: 310955
Still getting it with Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9a9pre) Gecko/2007100705 Minefield/3.0a9pre ID:2007100705. 

This is the error message :

Erreur : uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMXULElement.boxObject]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: chrome://browser/content/tabbrowser.xml :: _notifyBackgroundTab :: line 2754"  data: no]

Maybe a wontfix ?
(In reply to comment #8)
> I don't see any errors from my trunk build.

[Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9.1a2pre) Gecko/2008072508 SeaMonkey/2.0a1pre] (home made) (W2Ksp4)

{{
Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIControllers.removeController]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: chrome://navigator/content/navigator.js :: Shutdown :: line 790"  data: no]
}}

Always in the JsConsole or after a few tries in the Browser.
Assignee: general → nobody
Severity: minor → normal
OS: Windows 98 → Windows 2000
QA Contact: general → general
Version: 1.7 Branch → Trunk
That sounds like a UI bug, not a DOM bug.  Please reassign or file a separate bug as appropriate.
No longer blocks: 310955
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.