Open Bug 992676 Opened 10 years ago Updated 2 years ago

onerror handler doesn't give access to event object

Categories

(Core :: DOM: Events, defect, P5)

x86_64
Windows 7
defect

Tracking

()

UNCONFIRMED

People

(Reporter: crimsteam, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0 (Beta/Release)
Build ID: 20140314220517

Steps to reproduce:

According to html5 onerror handler for body and frameset elements should be exposed on window (http://www.w3.org/html/wg/drafts/html/master/webappapis.html#event-handlers-on-elements,-document-objects,-and-window-objects) and it is correct, but we don't have access to event object, we get only a string (like e.message). Chrome working correctly, IE doesn't expose this event when use handler on body/frameset. 

Other event handler, like onload, onunload, onresieze works fine. If I find similar inconsistencies for event handler I will put them in this place.

Some test for better understanding:

<!DOCTYPE html>
<html>

<head>
</head>

<body>

	<p>Generate error for script (when running).</p>

	<p style="color: blue;">Detailed information for the captured events:</p>
	<p id="info"></p>

	<script>

		var info = document.getElementById("info");

		function readInfo(e){

			var data = "Interface: " + e
				+ "<br>" + "e.type: " + e.type
				+ "<br>" + "e.currentTarget: " + e.currentTarget
				+ "<br>" + "e.target: " + e.target
				+ "<br>" + "e.eventPhase: " + e.eventPhase;

			// Only for script error
			if (e == "[object ErrorEvent]"){

				data +=  "<br>" + "e.message: " + e.message
					+ "<br>" + "e.filename: " + e.filename
					+ "<br>" + "e.lineno: " + e.lineno
					+ "<br>" + "e.colno: " + e.colno
					+ "<br>" + "e.error: " + e.error + "<br><br>";

			}
			else{
				data += "<br><br>";
			}

			info.innerHTML = info.innerHTML + data;

		}

		document.body.onerror = readInfo;

		document.body.addEventListener("error", readInfo, true); // without invoke (correct)
		document.body.addEventListener("error", readInfo, false); // without invoke (correct)

		makeError(); // generate some JS error (undefined method)

	</script>

</body>

</html>
Version: 31 Branch → Trunk
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven't been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.