Bug 77611 - [browser] IE shows warning dialog when JS error occured
Summary: [browser] IE shows warning dialog when JS error occured
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: 3.1 RC2   Edit
Assignee: Grant Gayed CLA
QA Contact:
URL:
Whiteboard:
Keywords: usability
: 105951 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-11-03 08:54 EST by Benjamin Pasero CLA
Modified: 2005-08-08 15:12 EDT (History)
4 users (show)

See Also:


Attachments
Patch File (2.46 KB, patch)
2005-06-02 17:39 EDT, Jobi George CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Pasero CLA 2004-11-03 08:54:11 EST
Hi,

I thought there was already a bug report about this problem, but I did not find it.

When using the IE as Browser on Windows within a SWT application, any webpages
containing erroneus JavaScript will result in a warning dialog poping up, asking
wether to continue loading the page.

I just checked it with the IE, outside the SWT application, and found out that
its not showing any dialog, but a small warning icon in the status area at the
bottom left.

It would be cool, if SWT could handle that problem the same way with not showing
the dialog and maybe set a boolean flag indicating that JavaScript is malformed
on the current page.

The testpage I was using is:
http://sports.espn.go.com/nba/news/story?id=1914791&CMP=OTC-DT9705204233

Regards,
Ben
Comment 1 Benjamin Pasero CLA 2004-12-03 19:33:11 EST
From a user:
"In Internet Explorer, there is an option to only show a hint in the status bar,
instead of popping up the annoying window each time."

Is the SWT Browser widget somehow overiding this option? My normal IE is showing
JS Script errors inside the status bar.

Ben
Comment 2 Benjamin Pasero CLA 2005-02-07 09:27:28 EST
Any plans to resolve this issue? If not, does somebody know of the setting in
Internet Options that affects this popup?

Ben
Comment 3 Christophe Cornu CLA 2005-04-11 18:10:14 EDT

*** This bug has been marked as a duplicate of 49969 ***
Comment 4 Benjamin Pasero CLA 2005-04-11 18:15:22 EDT
Hm, duplicate of "IE5 - Browser badly resizes when it loses focus"?
Comment 5 Benjamin Pasero CLA 2005-04-27 03:07:02 EDT
Chris could you please reopen the bug, I dont see how Bug 49969 is connected to
this bug.

Ben
Comment 6 Christophe Cornu CLA 2005-04-27 09:25:02 EDT
Oops, typo
Comment 7 Benjamin Pasero CLA 2005-05-08 08:18:45 EDT
The Browser widget does not seem to respect some IE settings. It is possible to
disable JavaScript debugging in Internet Options, but this does not have any
effect on the Browser widget.

http://www.cnn.com is always a good candidate to show the Dialog:

public class Main {
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    Browser browser = new Browser(shell, SWT.NONE);
    browser.setUrl("http://www.cnn.com");

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
  }
}

Opening that site with my standalone IE does not show any dialog.

Ben
Comment 8 Jobi George CLA 2005-06-02 17:39:10 EDT
Created attachment 22280 [details]
Patch File 

I have a fix that will work in most of the cases except when you have a
javascript debugging enabled in which case MS debugger will show a message box.


When a script error is encountered the script engine component forwards the
error to the WebBrowser control, which then queries its ControlSite and calls
Exec method with the command group ID of CGID_DocHostCommandHandler and a
command ID of OLECMDID_SHOWSCRIPTERROR. If the host does not return S_OK,
MSHTML displays the default "An error has occurred on this page" error message.
In the patch I am suppressing the error , in future you might be able to throw
your custom error message. In Lotus Workplace Client DOMBrowser Component we
infact have an implementation that throws custom error message.

These are the changes -

1) Add in COM.java static variable

	public static final GUID CGID_DocHostCommandHandler =
COM.IIDFromString("{f38bc242-b950-11d1-8918-00c04fc2c836}");

2) Add following lines in the WebSite class , Exec() method


int Exec(int pguidCmdGroup, int nCmdID, int nCmdExecOpt, int pvaIn, int pvaOut)
{
	
	if (pguidCmdGroup != 0)
	{	
		GUID guid = new GUID();
		COM.MoveMemory(guid, pguidCmdGroup, GUID.sizeof);
		if (COM.IsEqualGUID(guid, COM.CGID_DocHostCommandHandler))
		{
			if (nCmdID == OLECMDID_SHOWSCRIPTERROR) 
				return COM.S_OK;
			else
				return OLECMDERR_E_UNKNOWNGROUP;
		}
	}
Comment 9 Benjamin Pasero CLA 2005-06-03 03:00:20 EDT
Cool! I would really vote to get thix fix into 3.1!

Ben
Comment 10 kent gibson CLA 2005-06-03 06:50:14 EDT
me too a fix in 3.1 would be grand.
Comment 11 Grant Gayed CLA 2005-06-03 12:02:16 EDT
Thanks for the patch Jobi.  Suppressing the javascript errors silently is not 
ideal, but will make embedded IE be consistent with embedded Mozilla and 
Safari.  Fixed > 0603.

The ideal solution is to have a callback that allows the client to handle the 
error in a context-appropriate way.  This is something to consider post-3.1, so 
I've logged bug 98302.
Comment 12 Grant Gayed CLA 2005-08-08 15:12:42 EDT
*** Bug 105951 has been marked as a duplicate of this bug. ***