Bug 1333800 - Part a: Make non262/extensions/regress-50447-1.js more robust against changes in the filenames; rs=Waldo
authorMs2ger <Ms2ger@igalia.com>
Mon, 09 Jul 2018 10:59:36 +0200
changeset 815585 a197a960866b4c074633f82d4984d792d4d6a1df
parent 815584 3da753ca1fb121f8a17a52fde9136773c8e0a270
child 815586 0f277c17a06f1a28ad73b3009027b690228acbba
push id115563
push userbmo:ntim.bugs@gmail.com
push dateMon, 09 Jul 2018 12:45:57 +0000
reviewersWaldo
bugs1333800, 50447
milestone63.0a1
Bug 1333800 - Part a: Make non262/extensions/regress-50447-1.js more robust against changes in the filenames; rs=Waldo The next patch will pass absolute paths to the shell, and those will end up in the strings checked in this test.
js/src/tests/non262/extensions/regress-50447-1.js
--- a/js/src/tests/non262/extensions/regress-50447-1.js
+++ b/js/src/tests/non262/extensions/regress-50447-1.js
@@ -94,29 +94,28 @@ function test2()
 {
   /* generate an error with only msg property */
 
 
   /* note this test incorporates the path to the
      test file and assumes the path to the test case
      is a subdirectory of the directory containing jsDriver.pl
   */
-  var expectedLine = 109;
+  var expectedLine = 106;
   var expectedFileName = 'non262/extensions/regress-50447-1.js';
-  if (typeof document != "undefined") {
-    expectedFileName = document.location.href.
-      replace(/[^\/]*(\?.*)$/, '') +
-      expectedFileName;
-  }
+  var expectedSource = /\(new InternalError\("msg", "([^"]+)", ([0-9]+)\)\)/;
+
   var e = new InternalError ("msg");
-  reportCompare ("(new InternalError(\"msg\", \"" +
-		 expectedFileName + "\", " + expectedLine + "))",
-		 normalize(e.toSource()),
-		 "toSource() returned unexpected result.");
-  reportCompare (expectedFileName, normalize(e.fileName),
+
+  var actual = expectedSource.exec(e.toSource());
+  reportCompare (normalize(actual[1]).endsWith(expectedFileName), true,
+		 "toSource() returned unexpected result (filename).");
+  reportCompare (actual[2], String(expectedLine),
+		 "toSource() returned unexpected result (line).");
+  reportCompare (normalize(e.fileName).endsWith(expectedFileName), true,
 		 "fileName property returned unexpected value.");
   reportCompare (expectedLine, e.lineNumber,
 		 "lineNumber property returned unexpected value.");
 
 
 }
 
 
@@ -126,44 +125,43 @@ function test3()
 
   /* note this test incorporates the path to the
      test file and assumes the path to the test case
      is a subdirectory of the directory containing jsDriver.pl
   */
 
 
 
+  var expectedLine = 10;
   var expectedFileName = 'non262/extensions/regress-50447-1.js';
-  if (typeof document != "undefined") {
-    expectedFileName = document.location.href.
-      replace(/[^\/]*(\?.*)$/, '') +
-      expectedFileName;
-  }
+  var expectedSource = /\(new InternalError\("msg", "([^"]+)", ([0-9]+)\)\)/;
 
   var e = new InternalError ("msg");
-  e.lineNumber = 10;
-  reportCompare ("(new InternalError(\"msg\", \"" +
-		 expectedFileName + "\", 10))",
-		 normalize(e.toSource()),
-		 "toSource() returned unexpected result.");
-  reportCompare (expectedFileName, normalize(e.fileName),
+  e.lineNumber = expectedLine;
+
+  var actual = expectedSource.exec(e.toSource());
+  reportCompare (normalize(actual[1]).endsWith(expectedFileName), true,
+		 "toSource() returned unexpected result (filename).");
+  reportCompare (actual[2], String(expectedLine),
+		 "toSource() returned unexpected result (line).");
+  reportCompare (normalize(e.fileName).endsWith(expectedFileName), true,
 		 "fileName property returned unexpected value.");
-  reportCompare (10, e.lineNumber,
+  reportCompare (expectedLine, e.lineNumber,
 		 "lineNumber property returned unexpected value.");
 
 
 }
 
 
 function test4()
 {
   /* generate an error with only msg and filename properties */
 
 
-  var expectedLine = 163;
+  var expectedLine = 161;
 
   var e = new InternalError ("msg", "file");
   reportCompare ("(new InternalError(\"msg\", \"file\", " + expectedLine + "))",
 		 e.toSource(),
 		 "toSource() returned unexpected result.");
   reportCompare ("file", e.fileName,
 		 "fileName property returned unexpected value.");
   reportCompare (expectedLine, e.lineNumber,