View | Details | Raw Unified | Return to bug 84620
Collapse All | Expand All

(-)Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java (-1 / +11 lines)
Lines 47-53 Link Here
47
	int refCount, lastKeyCode, lastCharCode, authCount;
47
	int refCount, lastKeyCode, lastCharCode, authCount;
48
	int /*long*/ request;
48
	int /*long*/ request;
49
	Point location, size;
49
	Point location, size;
50
	boolean visible, isChild, ignoreDispose, isRetrievingBadCert, isViewingErrorPage;
50
	boolean visible, isChild, ignoreDispose, isRetrievingBadCert, isViewingErrorPage, ignoreAllMessages;
51
	Shell tip = null;
51
	Shell tip = null;
52
	Listener listener;
52
	Listener listener;
53
	Vector unhookedDOMWindows = new Vector ();
53
	Vector unhookedDOMWindows = new Vector ();
Lines 2097-2102 Link Here
2097
}
2097
}
2098
2098
2099
void onDispose (Display display) {
2099
void onDispose (Display display) {
2100
	/* invoke onbeforeunload handler(s) */
2101
	if (!isClosing) {
2102
		LocationListener[] oldLocationListeners = locationListeners;
2103
		locationListeners = new LocationListener[0];
2104
		ignoreAllMessages = true;
2105
		execute ("window.location.replace('about:blank');"); //$NON-NLS-1$
2106
		ignoreAllMessages = false;
2107
		locationListeners = oldLocationListeners;	
2108
	}
2109
2100
	int rc = webBrowser.RemoveWebBrowserListener (weakReference.getAddress (), nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID);
2110
	int rc = webBrowser.RemoveWebBrowserListener (weakReference.getAddress (), nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID);
2101
	if (rc != XPCOM.NS_OK) error (rc);
2111
	if (rc != XPCOM.NS_OK) error (rc);
2102
2112
(-)Eclipse SWT Mozilla/common/org/eclipse/swt/browser/PromptService2.java (-2 / +8 lines)
Lines 221-227 Link Here
221
221
222
int Confirm (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ _retval) {
222
int Confirm (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ _retval) {
223
	Browser browser = getBrowser (aParent);
223
	Browser browser = getBrowser (aParent);
224
	
224
225
	if (browser != null && ((Mozilla)browser.webBrowser).ignoreAllMessages) {
226
		int[] result = {1};
227
		XPCOM.memmove (_retval, result, 4); /* PRBool */
228
		return XPCOM.NS_OK;
229
	}
230
225
	int length = XPCOM.strlen_PRUnichar (aDialogTitle);
231
	int length = XPCOM.strlen_PRUnichar (aDialogTitle);
226
	char[] dest = new char[length];
232
	char[] dest = new char[length];
227
	XPCOM.memmove (dest, aDialogTitle, length * 2);
233
	XPCOM.memmove (dest, aDialogTitle, length * 2);
Lines 238-244 Link Here
238
	messageBox.setMessage (textLabel);
244
	messageBox.setMessage (textLabel);
239
	int id = messageBox.open ();
245
	int id = messageBox.open ();
240
	int[] result = {id == SWT.OK ? 1 : 0};
246
	int[] result = {id == SWT.OK ? 1 : 0};
241
	XPCOM.memmove (_retval, result, 4);
247
	XPCOM.memmove (_retval, result, 4); /* PRBool */
242
	return XPCOM.NS_OK;
248
	return XPCOM.NS_OK;
243
}
249
}
244
250
(-)Eclipse SWT Browser/win32/org/eclipse/swt/browser/WebSite.java (-2 / +2 lines)
Lines 27-33 Link Here
27
	COMObject iOleCommandTarget;
27
	COMObject iOleCommandTarget;
28
	COMObject iAuthenticate;
28
	COMObject iAuthenticate;
29
	COMObject iDispatch;
29
	COMObject iDispatch;
30
	boolean ignoreNextMessage;
30
	boolean ignoreNextMessage, ignoreAllMessages;
31
	Boolean canExecuteApplets;
31
	Boolean canExecuteApplets;
32
32
33
	static final int OLECMDID_SHOWSCRIPTERROR = 40;
33
	static final int OLECMDID_SHOWSCRIPTERROR = 40;
Lines 412-418 Link Here
412
/* IDocHostShowUI */
412
/* IDocHostShowUI */
413
413
414
int ShowMessage(int /*long*/ hwnd, int /*long*/ lpstrText, int /*long*/ lpstrCaption, int dwType, int /*long*/ lpstrHelpFile, int dwHelpContext, int /*long*/ plResult) {
414
int ShowMessage(int /*long*/ hwnd, int /*long*/ lpstrText, int /*long*/ lpstrCaption, int dwType, int /*long*/ lpstrHelpFile, int dwHelpContext, int /*long*/ plResult) {
415
	boolean ignore = ignoreNextMessage;
415
	boolean ignore = ignoreNextMessage || ignoreAllMessages;
416
	ignoreNextMessage = false;
416
	ignoreNextMessage = false;
417
	return ignore ? COM.S_OK : COM.S_FALSE;
417
	return ignore ? COM.S_OK : COM.S_FALSE;
418
}
418
}
(-)Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java (-2 / +10 lines)
Lines 22-28 Link Here
22
class IE extends WebBrowser {
22
class IE extends WebBrowser {
23
23
24
	OleFrame frame;
24
	OleFrame frame;
25
	OleControlSite site;
25
	WebSite site;
26
	OleAutomation auto;
26
	OleAutomation auto;
27
	OleListener domListener;
27
	OleListener domListener;
28
	OleAutomation[] documents = new OleAutomation[0];
28
	OleAutomation[] documents = new OleAutomation[0];
Lines 271-277 Link Here
271
					browser.notifyListeners (e.type, e);
271
					browser.notifyListeners (e.type, e);
272
					e.type = SWT.NONE;
272
					e.type = SWT.NONE;
273
273
274
//					execute("window.location.href='about:blank';");
274
					/* invoke onbeforeunload handler(s) */
275
					if (!isClosing) {
276
						LocationListener[] oldLocationListeners = locationListeners;
277
						locationListeners = new LocationListener[0];
278
						site.ignoreAllMessages = true;
279
						execute ("window.location.href='about:blank'"); //$NON-NLS-1$
280
						site.ignoreAllMessages = false;
281
						locationListeners = oldLocationListeners;
282
					}
275
283
276
					/*
284
					/*
277
					* It is possible for the Browser's OLE frame to have been disposed
285
					* It is possible for the Browser's OLE frame to have been disposed
(-)Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java (-6 / +18 lines)
Lines 40-46 Link Here
40
	String url = ""; //$NON-NLS-1$
40
	String url = ""; //$NON-NLS-1$
41
	Point location;
41
	Point location;
42
	Point size;
42
	Point size;
43
	boolean statusBar = true, toolBar = true, ignoreDispose;
43
	boolean statusBar = true, toolBar = true, ignoreDispose, acceptAllBeforeUnloadConfirms;
44
	//TEMPORARY CODE
44
	//TEMPORARY CODE
45
//	boolean doit;
45
//	boolean doit;
46
46
Lines 293-298 Link Here
293
					browser.notifyListeners (e.type, e);
293
					browser.notifyListeners (e.type, e);
294
					e.type = SWT.NONE;
294
					e.type = SWT.NONE;
295
295
296
					/* invoke onbeforeunload handler(s) */
297
					if (!isClosing) {
298
						acceptAllBeforeUnloadConfirms = true;
299
						close (); 
300
						acceptAllBeforeUnloadConfirms = false;
301
					}
302
296
					OS.RemoveEventHandler(windowBoundsHandler);
303
					OS.RemoveEventHandler(windowBoundsHandler);
297
					windowBoundsHandler = 0;
304
					windowBoundsHandler = 0;
298
305
Lines 441-451 Link Here
441
	StringBuffer buffer = new StringBuffer ("function "); // $NON-NLS-1$
448
	StringBuffer buffer = new StringBuffer ("function "); // $NON-NLS-1$
442
	buffer.append (functionName);
449
	buffer.append (functionName);
443
	buffer.append ("(win) {\n"); // $NON-NLS-1$
450
	buffer.append ("(win) {\n"); // $NON-NLS-1$
444
	buffer.append ("var fn = win.onbeforeunload; if (fn != null) {var str = null; try {str = fn();} catch (e) {}"); // $NON-NLS-1$
451
	buffer.append ("var fn = win.onbeforeunload; if (fn != null) {try {var str = fn(); if (str != null) { "); // $NON-NLS-1$
445
	buffer.append ("if (str != null) {var result = window.external.callRunBeforeUnloadConfirmPanelWithMessage(str);if (!result) return false;}}"); // $NON-NLS-1$
452
	buffer.append ("var result = window.external.callRunBeforeUnloadConfirmPanelWithMessage(str); if (!result) return false;}} catch (e) {}} "); // $NON-NLS-1$
446
	buffer.append ("for (var i = 0; i < win.frames.length; i++) {var result = "); // $NON-NLS-1$
453
	buffer.append ("try {for (var i = 0; i < win.frames.length; i++) {var result = "); // $NON-NLS-1$
447
	buffer.append (functionName);
454
	buffer.append (functionName);
448
	buffer.append ("(win.frames[i]); if (!result) return false;} return true;"); // $NON-NLS-1$
455
	buffer.append ("(win.frames[i]); if (!result) return false;}} catch (e) {} return true;"); // $NON-NLS-1$
449
	buffer.append ("\n};"); // $NON-NLS-1$
456
	buffer.append ("\n};"); // $NON-NLS-1$
450
	execute (buffer.toString ());
457
	execute (buffer.toString ());
451
458
Lines 1490-1496 Link Here
1490
}
1497
}
1491
1498
1492
int callRunBeforeUnloadConfirmPanelWithMessage(int /*long*/ messageID, int /*long*/ arg) {
1499
int callRunBeforeUnloadConfirmPanelWithMessage(int /*long*/ messageID, int /*long*/ arg) {
1493
	int result = runBeforeUnloadConfirmPanelWithMessage (messageID, 0);
1500
	int result;
1501
	if (acceptAllBeforeUnloadConfirms) {
1502
		result = 1;
1503
	} else {
1504
		result = runBeforeUnloadConfirmPanelWithMessage (messageID, 0);
1505
	}
1494
	return Cocoa.objc_msgSend (Cocoa.C_NSNumber, Cocoa.S_numberWithBool, result);
1506
	return Cocoa.objc_msgSend (Cocoa.C_NSNumber, Cocoa.S_numberWithBool, result);
1495
}
1507
}
1496
1508
(-)Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java (-1 / +1 lines)
Lines 27-33 Link Here
27
	TitleListener[] titleListeners = new TitleListener[0];
27
	TitleListener[] titleListeners = new TitleListener[0];
28
	VisibilityWindowListener[] visibilityWindowListeners = new VisibilityWindowListener[0];
28
	VisibilityWindowListener[] visibilityWindowListeners = new VisibilityWindowListener[0];
29
	boolean jsEnabled = true;
29
	boolean jsEnabled = true;
30
	boolean jsEnabledChanged;
30
	boolean jsEnabledChanged, isClosing;
31
	int nextFunctionIndex = 1;
31
	int nextFunctionIndex = 1;
32
	Object evaluateResult;
32
	Object evaluateResult;
33
33
(-)Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java (+2 lines)
Lines 509-515 Link Here
509
public boolean close () {
509
public boolean close () {
510
	checkWidget();
510
	checkWidget();
511
	if (webBrowser.close ()) {
511
	if (webBrowser.close ()) {
512
		webBrowser.isClosing = true;
512
		dispose ();
513
		dispose ();
514
		webBrowser.isClosing = false;
513
		return true;
515
		return true;
514
	}
516
	}
515
	return false;
517
	return false;
(-)Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java (-6 / +18 lines)
Lines 31-37 Link Here
31
	String url = ""; //$NON-NLS-1$
31
	String url = ""; //$NON-NLS-1$
32
	Point location;
32
	Point location;
33
	Point size;
33
	Point size;
34
	boolean statusBar = true, toolBar = true, ignoreDispose;
34
	boolean statusBar = true, toolBar = true, ignoreDispose, acceptAllBeforeUnloadConfirms;
35
	int lastMouseMoveX, lastMouseMoveY;
35
	int lastMouseMoveX, lastMouseMoveY;
36
	//TEMPORARY CODE
36
	//TEMPORARY CODE
37
//	boolean doit;
37
//	boolean doit;
Lines 217-222 Link Here
217
					browser.notifyListeners (e.type, e);
217
					browser.notifyListeners (e.type, e);
218
					e.type = SWT.NONE;
218
					e.type = SWT.NONE;
219
219
220
					/* invoke onbeforeunload handler(s) */
221
					if (!isClosing) {
222
						acceptAllBeforeUnloadConfirms = true;
223
						close (); 
224
						acceptAllBeforeUnloadConfirms = false;
225
					}
226
220
					e.display.setData(ADD_WIDGET_KEY, new Object[] {delegate, null});
227
					e.display.setData(ADD_WIDGET_KEY, new Object[] {delegate, null});
221
228
222
					Safari.this.webView.setFrameLoadDelegate(null);
229
					Safari.this.webView.setFrameLoadDelegate(null);
Lines 415-425 Link Here
415
	StringBuffer buffer = new StringBuffer ("function "); // $NON-NLS-1$
422
	StringBuffer buffer = new StringBuffer ("function "); // $NON-NLS-1$
416
	buffer.append (functionName);
423
	buffer.append (functionName);
417
	buffer.append ("(win) {\n"); // $NON-NLS-1$
424
	buffer.append ("(win) {\n"); // $NON-NLS-1$
418
	buffer.append ("var fn = win.onbeforeunload; if (fn != null) {var str = null; try {str = fn();} catch (e) {}"); // $NON-NLS-1$
425
	buffer.append ("var fn = win.onbeforeunload; if (fn != null) {try {var str = fn(); if (str != null) { "); // $NON-NLS-1$
419
	buffer.append ("if (str != null) {var result = window.external.callRunBeforeUnloadConfirmPanelWithMessage(str);if (!result) return false;}}"); // $NON-NLS-1$
426
	buffer.append ("var result = window.external.callRunBeforeUnloadConfirmPanelWithMessage(str); if (!result) return false;}} catch (e) {}} "); // $NON-NLS-1$
420
	buffer.append ("for (var i = 0; i < win.frames.length; i++) {var result = "); // $NON-NLS-1$
427
	buffer.append ("try {for (var i = 0; i < win.frames.length; i++) {var result = "); // $NON-NLS-1$
421
	buffer.append (functionName);
428
	buffer.append (functionName);
422
	buffer.append ("(win.frames[i]); if (!result) return false;} return true;"); // $NON-NLS-1$
429
	buffer.append ("(win.frames[i]); if (!result) return false;}} catch (e) {} return true;"); // $NON-NLS-1$
423
	buffer.append ("\n};"); // $NON-NLS-1$
430
	buffer.append ("\n};"); // $NON-NLS-1$
424
	execute (buffer.toString ());
431
	execute (buffer.toString ());
425
432
Lines 1067-1073 Link Here
1067
}
1074
}
1068
1075
1069
NSNumber callRunBeforeUnloadConfirmPanelWithMessage(int /*long*/ messageID, int /*long*/ arg) {
1076
NSNumber callRunBeforeUnloadConfirmPanelWithMessage(int /*long*/ messageID, int /*long*/ arg) {
1070
	boolean result = webView_runBeforeUnloadConfirmPanelWithMessage_initiatedByFrame (0, messageID, 0);
1077
	boolean result;
1078
	if (acceptAllBeforeUnloadConfirms) {
1079
		result = true;
1080
	} else {
1081
		result = webView_runBeforeUnloadConfirmPanelWithMessage_initiatedByFrame (0, messageID, 0);
1082
	}
1071
	return NSNumber.numberWithBool (result);
1083
	return NSNumber.numberWithBool (result);
1072
}
1084
}
1073
1085

Return to bug 84620