Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 344710

Summary: [editor] [Chrome] NPE when using mouse wheel
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: ClientAssignee: Felipe Heidrich <eclipse.felipe>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: eclipse.felipe, Silenio_Quarti
Version: 0.2   
Target Milestone: 0.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mark Macdonald CLA 2011-05-04 10:14:14 EDT
Orion 0.2 M7

1. Using Chrome, go to /examples/minimaleditor.html
2. Use the mouse wheel to scroll up and down.
3. You'll get a bunch of errors like this:

Uncaught TypeError: Cannot read property 'lineIndex' of null    editor.js:1964
Editor._handleMouseWheel    editor.js:1964
Editor._hookEvents.handlers.push.handler    editor.js:3522
Comment 1 Felipe Heidrich CLA 2011-05-04 10:47:56 EDT
This code is wrong:

if (isSafari) {
	var lineDiv = e.target;
	while (lineDiv.lineIndex === undefined) { 
		lineDiv = lineDiv.parentNode; 
	}
	this._mouseWheelLine = lineDiv;
}


it should be:

if (isSafari) {
	var lineDiv = e.target;
	while (lineDiv && lineDiv.lineIndex === undefined) { 
		lineDiv = lineDiv.parentNode; 
	}
	this._mouseWheelLine = lineDiv;
}

That said, this should not be your problem since this code only runs on Safari and you are on Chrome. Unless isSafari is set wrong.
Comment 2 Mark Macdonald CLA 2011-05-04 10:59:41 EDT
> That said, this should not be your problem since this code only runs on Safari
> and you are on Chrome. Unless isSafari is set wrong.

Running Chrome (11.0.696.60)

> navigator.userAgent
> "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.60 Safari/534.24"

I guess mentioning Mozilla, WebKit, Gecko and Chrome wasn't enough, they had to throw in Safari too ;)
Comment 3 Felipe Heidrich CLA 2011-05-04 11:09:05 EDT
(In reply to comment #2)
> > That said, this should not be your problem since this code only runs on Safari
> > and you are on Chrome. Unless isSafari is set wrong.
> Running Chrome (11.0.696.60)
> > navigator.userAgent
> > "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.60 Safari/534.24"
> I guess mentioning Mozilla, WebKit, Gecko and Chrome wasn't enough, they had to
> throw in Safari too ;)

That explains why isSafari is set. Our user agent detection code is pretty weak in the editor:

var isSafari = navigator.userAgent.indexOf("Safari") !== -1;
Comment 4 Felipe Heidrich CLA 2011-05-05 11:29:34 EDT
I fixed the null pointer
http://git.eclipse.org/c/e4/org.eclipse.orion.client.git/commit/?id=d3e097cef549088e353b3ad3dc056a9495c037dd

I filed Bug 344749 to track the problem(s) in our user agent detection code.