| 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/. */ |
| 5 | |
| 6 | gTestfile = 'instanceof-003.js'; |
| 7 | |
| 8 | /** |
| 9 | File Name: instanceof-003.js |
| 10 | ECMA Section: |
| 11 | Description: http://bugzilla.mozilla.org/show_bug.cgi?id=7635 |
| 12 | |
| 13 | js> function Foo() {} |
| 14 | js> theproto = {}; |
| 15 | [object Object] |
| 16 | js> Foo.prototype = theproto |
| 17 | [object Object] |
| 18 | js> theproto instanceof Foo |
| 19 | true |
| 20 | |
| 21 | I think this should be 'false' |
| 22 | |
| 23 | |
| 24 | Author: [email protected] |
| 25 | Date: 12 november 1997 |
| 26 | |
| 27 | Modified to conform to ECMA3 |
| 28 | https://bugzilla.mozilla.org/show_bug.cgi?id=281606 |
| 29 | */ |
| 30 | var SECTION = "instanceof-003"; |
| 31 | var VERSION = "ECMA_2"; |
| 32 | var TITLE = "instanceof operator"; |
| 33 | var BUGNUMBER ="7635"; |
| 34 | |
| 35 | startTest(); |
| 36 | |
| 37 | function Foo() {}; |
| 38 | theproto = {}; |
| 39 | Foo.prototype = theproto; |
| 40 | |
| 41 | AddTestCase( |
| 42 | "function Foo() = {}; theproto = {}; Foo.prototype = theproto; " + |
| 43 | "theproto instanceof Foo", |
| 44 | false, |
| 45 | theproto instanceof Foo ); |
| 46 | |
| 47 | |
| 48 | var o = {}; |
| 49 | |
| 50 | // https://bugzilla.mozilla.org/show_bug.cgi?id=281606 |
| 51 | try |
| 52 | { |
| 53 | AddTestCase( |
| 54 | "o = {}; o instanceof o", |
| 55 | "error", |
| 56 | o instanceof o ); |
| 57 | } |
| 58 | catch(e) |
| 59 | { |
| 60 | AddTestCase( |
| 61 | "o = {}; o instanceof o", |
| 62 | "error", |
| 63 | "error" ); |
| 64 | } |
| 65 | |
| 66 | test(); |