window.onUnload don't work when the page is in a popup
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
People
(Reporter: matutetandil, Unassigned)
References
Details
(Keywords: regression)
Attachments
(2 files)
User Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1 Steps to reproduce: I have a page that opens another page in a popup window... the second page has an event that must run when the popup is closed (i do that with window.onUnload, or window.onBeforeUnload), thats don't works on Firefox 5 and 6, but works on Firefox 3. Here is the code of both pages: Page 1: <html> <head> <title>onunload test</title> <script type="text/javascript"> open("test.html","John","toolbar=0"); </script> </head> <body> <p>popup</p> </body> </html> Page 2: <html> <head> <title>onunload test</title> <script type="text/javascript"> window.onunload = unloadPage; function unloadPage() { alert("unload event detected!"); } </script> </head> <body> <p>Reload a new page into the browser<br /> to fire the unload event for this page.</p> <p>You can also use the back or forward buttons<br /> to load a new page and fire this event.</p> </body> </html> Actual results: The event don't get firered... so nothing happens. I tried putting the event on the body, but nothing happens. Expected results: The event should be firered
Recently I test the issue in Firefox 3.0 and works, version 3.5.11 and 3.6.8 don't work
If I change the event onUnload with onBeforeUnload, it works OK...
Comment 3•13 years ago
|
||
Confirmed on http://hg.mozilla.org/mozilla-central/rev/198c7de0699d Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0a1) Gecko/20110824 Firefox/9.0a1 ID:20110824030813 And an error in Error Console: Error: uncaught exception: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIWindowWatcher.openWindow]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: resource:///components/nsPrompter.js :: openModalWindow :: line 416" data: no] Regression window(m-c nightly): Works: http://hg.mozilla.org/mozilla-central/rev/9dbded90af2a Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2a1pre) Gecko/20090113 Firefox/3.2a1pre ID:20090113035246 Fails: http://hg.mozilla.org/mozilla-central/rev/89811ac1b35a Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2a1pre) Gecko/20090114 Firefox/3.2a1pre ID:20090114034711 Pushlog: http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=9dbded90af2a&tochange=89811ac1b35a Triggered by: 8dae102faa15 Boris Zbarsky — Bug 465993. When opening a dependent window with an invisible non-chrome parent, throw. r=jst,ere, sr=jst
It's really weird, but the only way that I found to get the code inside the function that i called when the popup close works its to put an alert at the end. Otherwise don't work ie: funtion xx(){ ... some code ... alert("bla bla bla"); //if I comment the alert, the code don't work }
(In reply to Matias from comment #4) > It's really weird, but the only way that I found to get the code inside the > function that i called when the popup close works its to put an alert at the > end. Otherwise don't work > ie: > funtion xx(){ > ... > some code > ... > alert("bla bla bla"); //if I comment the alert, the code don't work > } This is not an error... i find a solution to that... sorry... (no needs the alert)
Comment 6•13 years ago
|
||
This sounds like expected behavior: parenting a modal dialog to an already-closed window is not allowed.... The event handler works fine; what you can't do is open an alert from it!
Comment 7•13 years ago
|
||
(In reply to Boris Zbarsky (:bz) from comment #6) > This sounds like expected behavior: parenting a modal dialog to an > already-closed window is not allowed.... The event handler works fine; what > you can't do is open an alert from it! How about the following case? [STR] 1 Start Firefox 2 Open attachment in first Tab 3 Open attachment in second Tab 4 Press Ctrl+w 5 Press Ctrl+w [ACTUAL] After step 4, you got an alert box. But step 5, no alert box pops up and close window. [EXPECTED] I think both step should be same behavior (an alert box should appears),
Yes... that's right... the problem is that firefox seems not to handle the onUnload event in a Popup... (In reply to Alice0775 White from comment #7) > Created attachment 555484 [details] > this is not testcase, just for comment7 > > (In reply to Boris Zbarsky (:bz) from comment #6) > > This sounds like expected behavior: parenting a modal dialog to an > > already-closed window is not allowed.... The event handler works fine; what > > you can't do is open an alert from it! > > How about the following case? > > [STR] > 1 Start Firefox > 2 Open attachment in first Tab > 3 Open attachment in second Tab > > 4 Press Ctrl+w > 5 Press Ctrl+w > > [ACTUAL] > After step 4, you got an alert box. > But step 5, no alert box pops up and close window. > > [EXPECTED] > I think both step should be same behavior (an alert box should appears),
Comment 10•12 years ago
|
||
is this related to my problem at all please? https://getsatisfaction.com/mozilla_messaging/topics/error_sending_mail_without_opening_modal_window?rfm=1
Comment 11•11 years ago
|
||
any update on this issue? Summary: window.onUnload and window.onBeforeUnload don't work when the page is in a popup → window.onUnload don't work when the page is in a popup need to clear session from popup when window is unloading. Thanks,
Comment 12•9 years ago
|
||
4 years on, and this is still broken... Sample Code: window.onbeforeunload = function() { return "Refreshing this page will duplicate your requests, please refrain from doing so!"; } When used the page does not inherit the custom message, and instead returns the default message from Firefox: "This page is asking you to confirm that you want to leave - data you have entered may not be saved." With the "Leave Page" and "Stay on Page" buttons. It can't be that hard to add a conditional to check for the existence of a set return, and then inherit that as the dialog text, rather than always spew a static string..
Comment 14•8 years ago
|
||
hi, I am facing this problem in current release version 44.0.2. Scenario: I try to open a window using parameters. Window opens correctly. but when I close the window using onbeforeunload(), the method that I intend to execute underneath doesn't fire. This above problem is not faced when the same page is not opened in wiondow. onbeforeunload works correctly there. I have seen bug-1247945 which is marked as dupe. This bug status is marked as NEW. Shall I consider that It's not fixed at all? Or am I missing any piece here? Thank you.
Comment 15•8 years ago
|
||
(In reply to Sandeep Pareek from comment #14) > hi, > I am facing this problem in current release version 44.0.2. > Scenario: > > I try to open a window using parameters. Window opens correctly. > but when I close the window using onbeforeunload(), the method that I intend > to execute underneath doesn't fire. > This above problem is not faced when the same page is not opened in wiondow. > onbeforeunload works correctly there. > > I have seen bug-1247945 which is marked as dupe. This bug status is marked > as NEW. Shall I consider that It's not fixed at all? Or am I missing any > piece here? > Thank you. It's not fixed yet I am very disappointed by Firefox
Comment 16•8 years ago
|
||
Invalid. In the original example, `alert()` is ignored in unload handler as per https://developer.mozilla.org/en-US/docs/Web/Events/unload . The `beforeunload` issue from comment14 is irrelevant to this ticket.
Comment 17•8 years ago
|
||
(In reply to Ivan Pozdeev from comment #16) > The `beforeunload` issue from comment14 is irrelevant to this ticket. Then is bug 1247945 misduped?
Comment 18•8 years ago
|
||
(In reply to Masatoshi Kimura [:emk] from comment #17) > (In reply to Ivan Pozdeev from comment #16) > > The `beforeunload` issue from comment14 is irrelevant to this ticket. > > Then is bug 1247945 misduped? No. It deals with `alert()` in onunload handler, too.
Assignee | ||
Updated•5 years ago
|
Comment 19•2 years ago
|
||
I can't manage to reproduce this issue on my machines Win 10 and MacOS 11 on the latest Nightly. No alerts message received from accessing the html from the description and close both pages(pop-up and first page). Same behaviour on Chrome. Maybe the test case(html) should be updated.
Alice, is this issue still reproducible on the latest Nightly?
I noticed that Matias account is not active anymore.
Thanks.
Comment 20•2 years ago
|
||
Steps to reproduce:
- Open
Browser Console
(Ctrl+Shift+Alt+I) and EnableShow Content Messages
- Open attached Bug681636-p.html in a new tab
- Close the tab
Actual Results:
Browser Console
does not output unload event detected!
.
Expected Results:
Browser Console
should output unload event detected!
.
Comment 21•2 years ago
|
||
In the process of migrating remaining bugs to the new severity system, the severity for this bug cannot be automatically determined. Please retriage this bug using the new severity system.
Updated•2 years ago
|
Comment 22•2 years ago
|
||
The problem with the example in comment 20 is that the console.log
API doesn't record the log
call from the unload handler. An XHR triggered from the unload handler with the same STR does work, though, and triggers browser console output.
Description
•