Closed Bug 370096 Opened 17 years ago Closed 17 years ago

onbeforeunload doesn't work when closing tab/window

Categories

(Camino Graveyard :: General, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Camino1.6

People

(Reporter: MatsPalmgren_bugz, Assigned: stuart.morgan+bugzilla)

References

()

Details

(Keywords: fixed1.8.1.8, Whiteboard: [camino-1.5.2])

Attachments

(1 file, 1 obsolete file)

onbeforeunload doesn't work

STEPS TO REPRODUCE
1. load URL (testcase from bug 284596)
2. type Cmd+W or Cmd+Q

ACTUAL RESULT
Window is closed without any popup dialog appearing

EXPECTED RESULT
popup dialog appears giving the user a chance to veto the close/quit.

PLATFORMS AND BUILDS TESTED
Camino trunk debug build, a few days old, on MacOSX 10.4.8
OS: Linux → Mac OS X
Hardware: PC → Macintosh
Fixing summary. It works if you navigate away from the page, just not if you close the tab/window. Are there embedding hooks we can to tie into to give handlers a chance to run?
Component: Tabbed Browsing → General
QA Contact: tabbed.browsing → general
Summary: onbeforeunload doesn't work → onbeforeunload doesn't work when closing tab/window
Happens on branch, too.
Version: Trunk → unspecified
Assignee: nobody → stuart.morgan
Attached patch fix (obsolete) — Splinter Review
Adds a CHBV method to check onunload events, and sets up the chrome to call it whenever closing tabs or windows. I also renamed BW's confusingly-named |windowClosed| method, which has always just really meant that the browser view was closed, since that drove me crazy while figuring out how to wire this up.
Attachment #275428 - Flags: review?(joshmoz)
Target Milestone: --- → Camino1.6
Er, s/onunload/onbeforeunload/.
Attachment #275428 - Flags: review?(joshmoz) → review+
Attachment #275428 - Flags: superreview?(mikepinkerton)
+  // Check all the winodws to see if any have tabs that shouldn't be closed.

fix typo.

+  NSArray* openWindows = [[[NSApp orderedWindows] copy] autorelease];

why copy? i don't see anything in here that changes the list while we're iterating.

+  int numTabs = [self numberOfTabViewItems];

const int?

looks good otherwise.
Attached patch v2Splinter Review
Comments addressed. Also fixes an early return I missed in applicationShouldTerminate that would skip onbeforeunloads if the general quit warning pref were off. It looks like a lot more change in MainController than it really is, since it's just reparenting a lot of existing code into an |if ([prefManager getBooleanPref:"camino.warn_when_closing" withSuccess:NULL])|.
Attachment #275428 - Attachment is obsolete: true
Attachment #278205 - Flags: superreview?(mikepinkerton)
Attachment #275428 - Flags: superreview?(mikepinkerton)
Comment on attachment 278205 [details] [diff] [review]
v2

sr=pink
Attachment #278205 - Flags: superreview?(mikepinkerton) → superreview+
Landed on trunk and MOZILLA_1_8_BRANCH.
Status: NEW → RESOLVED
Closed: 17 years ago
Keywords: testcasefixed1.8.1.7
Resolution: --- → FIXED
Since this is a web compat issue, we should consider this for 1.5.2 (if it can reasonably be backported).
Flags: camino1.5.2?
I'd like to see this bake for a little while, just to be safe, so it depends when we do 1.5.2
Stuart, are you satisfied with the baking now?  (Unfortunately, the hunk in MainController doesn't apply on the 1_5 branch; it'll need a little massaging because of the exceptions change.)
Yep, sounds good to me.
Flags: camino1.5.2? → camino1.5.2+
Landed on CAMINO_1_5_BRANCH.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: