Bug 568564. Suppress the script filename for cross-origin onerror events. r=jst
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 08 Jun 2010 15:58:26 -0400
changeset 43325 155d4a2be1bce19dd043bda5eaa1151cc1446bd7
parent 43324 6fce6521907aa973189449838eea6f935a371e2f
child 43326 e88b028a04833a3b97abae450d252b7b3e44a52a
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs568564
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 568564. Suppress the script filename for cross-origin onerror events. r=jst
content/base/test/test_bug461735.html
dom/base/nsJSEnvironment.cpp
--- a/content/base/test/test_bug461735.html
+++ b/content/base/test/test_bug461735.html
@@ -14,17 +14,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script type="application/javascript">
 window.onerror = function(message, uri, line) {
   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");
 }
 </script>
 <script src="bug461735-redirect1.sjs"></script>
 <script type="application/javascript">
 window.onerror = function(message, uri, line) {
   is(message, "c is not defined", "Should have correct error message");
   is(uri, "http://mochi.test:8888/tests/content/base/test/bug461735-post-redirect.js", "Unexpected error location URI");
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -470,16 +470,20 @@ public:
           NS_NAMED_LITERAL_STRING(xoriginMsg, "Script error.");
           if (sameOrigin) {
             errorevent.errorMsg = mErrorMsg.get();
             errorevent.lineNr = mLineNr;
           } else {
             NS_WARNING("Not same origin error!");
             errorevent.errorMsg = xoriginMsg.get();
             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.
+            errorevent.fileName = nsnull;
           }
 
           nsEventDispatcher::Dispatch(win, presContext, &errorevent, nsnull,
                                       &status);
         }
 
         sHandlingScriptError = PR_FALSE;
       }