js/src/tests/js1_5/extensions/regress-354541-04.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 //-----------------------------------------------------------------------------
     7 var BUGNUMBER = 354541;
     8 var summary = 'Regression to standard class constructors in case labels';
     9 var actual = '';
    10 var expect = '';
    12 //-----------------------------------------------------------------------------
    13 test();
    14 //-----------------------------------------------------------------------------
    16 function test()
    17 {
    18   enterFunc ('test');
    19   printBugNumber(BUGNUMBER);
    20   printStatus (summary + ': in function');
    22   String.prototype.trim = function() { return 'hallo'; };
    24   const S = String;
    25   const Sp = String.prototype;
    27   expect = 'hallo';
    28   var expectStringInvariant = true;
    29   var actualStringInvariant;
    30   var expectStringPrototypeInvariant = true;
    31   var actualStringPrototypeInvariant;
    33   if (typeof Script == 'undefined')
    34   {
    35     print('Test skipped. Script is not defined');
    36     reportCompare("Script not defined, Test skipped.",
    37                   "Script not defined, Test skipped.",
    38                   summary);
    39   }
    40   else
    41   {
    42     s = Script('var tmp = function(o) { switch(o) { case String: case 1: return ""; } }; actualStringInvariant = (String === S); actualStringPrototypeInvariant = (String.prototype === Sp); actual = "".trim();');
    43     try
    44     {
    45       s();
    46     }
    47     catch(ex)
    48     {
    49       actual = ex + '';
    50     }
    52     reportCompare(expect, actual, 'trim() returned');
    53     reportCompare(expectStringInvariant, actualStringInvariant, 'String invariant');
    54     reportCompare(expectStringPrototypeInvariant,
    55                   actualStringPrototypeInvariant,
    56                   'String.prototype invariant');
    57   }
    59   exitFunc ('test');
    60 }

mercurial