js/src/tests/ecma_5/strict/unbrand-this.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     3 /*
     4  * Any copyright is dedicated to the Public Domain.
     5  * http://creativecommons.org/licenses/publicdomain/
     6  */
     8 /* Test JSOP_UNBRANDTHIS's behavior on object and non-object |this| values. */
    10 function strict() {
    11   "use strict";
    12   this.insert = function(){ bar(); };
    13   function bar() {}
    14 }
    16 var exception;
    18 // Try 'undefined' as a |this| value.
    19 exception = null;
    20 try {
    21   strict.call(undefined);
    22 } catch (x) {
    23   exception = x;
    24 }
    25 assertEq(exception instanceof TypeError, true);
    27 // Try 'null' as a |this| value.
    28 exception = null;
    29 try {
    30   strict.call(null);
    31 } catch (x) {
    32   exception = x;
    33 }
    34 assertEq(exception instanceof TypeError, true);
    36 // An object as a |this| value should be fine.
    37 exception = null;
    38 try {
    39   strict.call({});
    40 } catch (x) {
    41   exception = x;
    42 }
    43 assertEq(exception, null);
    45 reportCompare(true, true);

mercurial