Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / tests / ecma_5 / strict / unbrand-this.js
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
3 /*
4  * Any copyright is dedicated to the Public Domain.
5  * http://creativecommons.org/licenses/publicdomain/
6  */
7
8 /* Test JSOP_UNBRANDTHIS's behavior on object and non-object |this| values. */
9
10 function strict() {
11   "use strict";
12   this.insert = function(){ bar(); };
13   function bar() {}
14 }
15
16 var exception;
17
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);
26
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);
35
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);
44
45 reportCompare(true, true);