Bug 568564. Suppress the script filename for cross-origin onerror events. Patch by Boris Zbarsky <bzbarsky@mit.edu>, r=jst, a1.9.0.next=dveditz

git-svn-id: svn://10.0.0.236/trunk@260880 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
alqahira%ardisson.org 2010-07-24 21:31:26 +00:00
parent 7095da4fbc
commit b31208c5bf
2 changed files with 18 additions and 1 deletions

View File

@ -17,21 +17,31 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=461735
</div> </div>
<pre id="test"> <pre id="test">
<script type="application/javascript"> <script type="application/javascript">
var errorFired = false;
window.onerror = function(message, uri, line) { window.onerror = function(message, uri, line) {
is(message, "Script error.", "Should have empty error message"); is(message, "Script error.", "Should have empty error message");
is(uri, "http://example.com/tests/content/base/test/bug461735-post-redirect.js", "Unexpected error location URI"); is(uri, "", "Should have empty error location URI");
is(line, 0, "Shouldn't have a line here"); is(line, 0, "Shouldn't have a line here");
errorFired = true;
} }
</script> </script>
<script src="bug461735-redirect1.sjs"></script> <script src="bug461735-redirect1.sjs"></script>
<script>
is(errorFired, true, "Should have error in redirected different origin script");
errorFired = false;
</script>
<script type="application/javascript"> <script type="application/javascript">
window.onerror = function(message, uri, line) { window.onerror = function(message, uri, line) {
is(message, "c is not defined", "Should have correct error message"); is(message, "c is not defined", "Should have correct error message");
is(uri, "http://localhost:8888/tests/content/base/test/bug461735-post-redirect.js", "Unexpected error location URI"); is(uri, "http://localhost:8888/tests/content/base/test/bug461735-post-redirect.js", "Unexpected error location URI");
is(line, 3, "Should have a line here"); is(line, 3, "Should have a line here");
errorFired = true;
} }
</script> </script>
<script src="bug461735-redirect2.sjs"></script> <script src="bug461735-redirect2.sjs"></script>
<script>
is(errorFired, true, "Should have error in same origin script");
</script>
</pre> </pre>
</body> </body>
</html> </html>

View File

@ -480,6 +480,13 @@ public:
NS_WARNING("Not same origin error!"); NS_WARNING("Not same origin error!");
errorevent.errorMsg = xoriginMsg.get(); errorevent.errorMsg = xoriginMsg.get();
errorevent.lineNr = 0; errorevent.lineNr = 0;
// FIXME: once the principal of the script is not tied to
// the filename, we can stop using the post-redirect
// filename if we want and remove this line. Note that
// apparently we can't handle null filenames in the error
// event dispatching code.
static PRUnichar nullFilename[] = { PRUnichar(0) };
errorevent.fileName = nullFilename;
} }
nsEventDispatcher::Dispatch(win, presContext, &errorevent, nsnull, nsEventDispatcher::Dispatch(win, presContext, &errorevent, nsnull,