js/src/tests/js1_5/extensions/regress-50447-1.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * vim: set ts=8 sts=4 et sw=4 tw=99:
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     8 /*
     9  * SUMMARY: New properties fileName, lineNumber have been added to Error objects
    10  * in SpiderMonkey. These are non-ECMA extensions and do not exist in Rhino.
    11  *
    12  * See http://bugzilla.mozilla.org/show_bug.cgi?id=50447
    13  *
    14  * 2005-04-05 Modified by bclary to support changes to error reporting
    15  *            which set default values for the error's fileName and
    16  *            lineNumber properties.
    17  */
    19 //-----------------------------------------------------------------------------
    20 var BUGNUMBER = 50447;
    21 var summary = 'Test (non-ECMA) Error object properties fileName, lineNumber';
    24 //-----------------------------------------------------------------------------
    25 test();
    26 //-----------------------------------------------------------------------------
    29 function test()
    30 {
    31   enterFunc ('test');
    32   printBugNumber(BUGNUMBER);
    33   printStatus (summary);
    35   testRealError();
    36   test1();
    37   test2();
    38   test3();
    39   test4();
    41   exitFunc('test');
    42 }
    44 // Normalize filenames so this test can work on Windows. This 
    45 // function is also used on strings that contain filenames.
    46 function normalize(filename)
    47 {
    48     // Also convert double-backslash to single-slash to handle
    49     // escaped filenames in string literals.
    50     return filename.replace(/\\{1,2}/g, '/');
    51 }
    53 function testRealError()
    54 {
    55   /* throw a real error, and see what it looks like */
    56   enterFunc ("testRealError");
    58   try
    59   {
    60     blabla;
    61   }
    62   catch (e)
    63   {
    64     if (e.fileName.search (/-50447-1\.js$/i) == -1)
    65       reportCompare('PASS', 'FAIL', "expected fileName to end with '-50447-1.js'");
    67     reportCompare(60, e.lineNumber,
    68 		  "lineNumber property returned unexpected value.");
    69   }
    71   exitFunc ("testRealError");
    72 }
    75 function test1()
    76 {
    77   /* generate an error with msg, file, and lineno properties */
    78   enterFunc ("test1");
    80   var e = new InternalError ("msg", "file", 2);
    81   reportCompare ("(new InternalError(\"msg\", \"file\", 2))",
    82 		 e.toSource(),
    83 		 "toSource() returned unexpected result.");
    84   reportCompare ("file", e.fileName,
    85 		 "fileName property returned unexpected value.");
    86   reportCompare (2, e.lineNumber,
    87 		 "lineNumber property returned unexpected value.");
    89   exitFunc ("test1");
    90 }
    93 function test2()
    94 {
    95   /* generate an error with only msg property */
    96   enterFunc ("test2");
    98   /* note this test incorporates the path to the
    99      test file and assumes the path to the test case
   100      is a subdirectory of the directory containing jsDriver.pl
   101   */
   102   var expectedLine = 109;
   103   var expectedFileName = 'js1_5/extensions/regress-50447-1.js';
   104   if (typeof document != "undefined") {
   105     expectedFileName = document.location.href.
   106       replace(/[^\/]*(\?.*)$/, '') +
   107       expectedFileName;
   108   }
   109   var e = new InternalError ("msg");
   110   reportCompare ("(new InternalError(\"msg\", \"" +
   111 		 expectedFileName + "\", " + expectedLine + "))",
   112 		 normalize(e.toSource()),
   113 		 "toSource() returned unexpected result.");
   114   reportCompare (expectedFileName, normalize(e.fileName),
   115 		 "fileName property returned unexpected value.");
   116   reportCompare (expectedLine, e.lineNumber,
   117 		 "lineNumber property returned unexpected value.");
   119   exitFunc ("test2");
   120 }
   123 function test3()
   124 {
   125   /* generate an error with only msg and lineNo properties */
   127   /* note this test incorporates the path to the
   128      test file and assumes the path to the test case
   129      is a subdirectory of the directory containing jsDriver.pl
   130   */
   132   enterFunc ("test3");
   134   var expectedFileName = 'js1_5/extensions/regress-50447-1.js';
   135   if (typeof document != "undefined") {
   136     expectedFileName = document.location.href.
   137       replace(/[^\/]*(\?.*)$/, '') +
   138       expectedFileName;
   139   }
   141   var e = new InternalError ("msg");
   142   e.lineNumber = 10;
   143   reportCompare ("(new InternalError(\"msg\", \"" +
   144 		 expectedFileName + "\", 10))",
   145 		 normalize(e.toSource()),
   146 		 "toSource() returned unexpected result.");
   147   reportCompare (expectedFileName, normalize(e.fileName),
   148 		 "fileName property returned unexpected value.");
   149   reportCompare (10, e.lineNumber,
   150 		 "lineNumber property returned unexpected value.");
   152   exitFunc ("test3");
   153 }
   156 function test4()
   157 {
   158   /* generate an error with only msg and filename properties */
   159   enterFunc ("test4");
   161   var expectedLine = 163;
   163   var e = new InternalError ("msg", "file");
   164   reportCompare ("(new InternalError(\"msg\", \"file\", " + expectedLine + "))",
   165 		 e.toSource(),
   166 		 "toSource() returned unexpected result.");
   167   reportCompare ("file", e.fileName,
   168 		 "fileName property returned unexpected value.");
   169   reportCompare (expectedLine, e.lineNumber,
   170 		 "lineNumber property returned unexpected value.");
   172   exitFunc ("test4");
   173 }

mercurial