Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | File Name: proto_12.js |
michael@0 | 9 | Section: |
michael@0 | 10 | Description: new PrototypeObject |
michael@0 | 11 | |
michael@0 | 12 | This tests Object Hierarchy and Inheritance, as described in the document |
michael@0 | 13 | Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 |
michael@0 | 14 | 15:19:34 on http://devedge.netscape.com/. Current URL: |
michael@0 | 15 | http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm |
michael@0 | 16 | |
michael@0 | 17 | No Multiple Inheritance |
michael@0 | 18 | |
michael@0 | 19 | Author: christine@netscape.com |
michael@0 | 20 | Date: 12 november 1997 |
michael@0 | 21 | */ |
michael@0 | 22 | |
michael@0 | 23 | var SECTION = "proto_12"; |
michael@0 | 24 | var VERSION = "JS1_3"; |
michael@0 | 25 | var TITLE = "No Multiple Inheritance"; |
michael@0 | 26 | |
michael@0 | 27 | startTest(); |
michael@0 | 28 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 29 | |
michael@0 | 30 | function Employee ( name, dept ) { |
michael@0 | 31 | this.name = name || ""; |
michael@0 | 32 | this.dept = dept || "general"; |
michael@0 | 33 | this.id = idCounter++; |
michael@0 | 34 | } |
michael@0 | 35 | function Manager () { |
michael@0 | 36 | this.reports = []; |
michael@0 | 37 | } |
michael@0 | 38 | Manager.prototype = new Employee(); |
michael@0 | 39 | |
michael@0 | 40 | function WorkerBee ( name, dept, projs ) { |
michael@0 | 41 | this.base = Employee; |
michael@0 | 42 | this.base( name, dept) |
michael@0 | 43 | this.projects = projs || new Array(); |
michael@0 | 44 | } |
michael@0 | 45 | WorkerBee.prototype = new Employee(); |
michael@0 | 46 | |
michael@0 | 47 | function SalesPerson () { |
michael@0 | 48 | this.dept = "sales"; |
michael@0 | 49 | this.quota = 100; |
michael@0 | 50 | } |
michael@0 | 51 | SalesPerson.prototype = new WorkerBee(); |
michael@0 | 52 | |
michael@0 | 53 | function Hobbyist( hobby ) { |
michael@0 | 54 | this.hobby = hobby || "yodeling"; |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | function Engineer ( name, projs, machine, hobby ) { |
michael@0 | 58 | this.base1 = WorkerBee; |
michael@0 | 59 | this.base1( name, "engineering", projs ) |
michael@0 | 60 | |
michael@0 | 61 | this.base2 = Hobbyist; |
michael@0 | 62 | this.base2( hobby ); |
michael@0 | 63 | |
michael@0 | 64 | this.projects = projs || new Array(); |
michael@0 | 65 | this.machine = machine || ""; |
michael@0 | 66 | } |
michael@0 | 67 | Engineer.prototype = new WorkerBee(); |
michael@0 | 68 | |
michael@0 | 69 | var idCounter = 1; |
michael@0 | 70 | |
michael@0 | 71 | var les = new Engineer( "Morris, Les", new Array("JavaScript"), "indy" ); |
michael@0 | 72 | |
michael@0 | 73 | Hobbyist.prototype.equipment = [ "horn", "mountain", "goat" ]; |
michael@0 | 74 | |
michael@0 | 75 | new TestCase( SECTION, |
michael@0 | 76 | "les.name", |
michael@0 | 77 | "Morris, Les", |
michael@0 | 78 | les.name ); |
michael@0 | 79 | |
michael@0 | 80 | new TestCase( SECTION, |
michael@0 | 81 | "les.dept", |
michael@0 | 82 | "engineering", |
michael@0 | 83 | les.dept ); |
michael@0 | 84 | |
michael@0 | 85 | Array.prototype.getClass = Object.prototype.toString; |
michael@0 | 86 | |
michael@0 | 87 | new TestCase( SECTION, |
michael@0 | 88 | "les.projects.getClass()", |
michael@0 | 89 | "[object Array]", |
michael@0 | 90 | les.projects.getClass() ); |
michael@0 | 91 | |
michael@0 | 92 | new TestCase( SECTION, |
michael@0 | 93 | "les.projects[0]", |
michael@0 | 94 | "JavaScript", |
michael@0 | 95 | les.projects[0] ); |
michael@0 | 96 | |
michael@0 | 97 | new TestCase( SECTION, |
michael@0 | 98 | "les.machine", |
michael@0 | 99 | "indy", |
michael@0 | 100 | les.machine ); |
michael@0 | 101 | |
michael@0 | 102 | new TestCase( SECTION, |
michael@0 | 103 | "les.hobby", |
michael@0 | 104 | "yodeling", |
michael@0 | 105 | les.hobby ); |
michael@0 | 106 | |
michael@0 | 107 | new TestCase( SECTION, |
michael@0 | 108 | "les.equpment", |
michael@0 | 109 | void 0, |
michael@0 | 110 | les.equipment ); |
michael@0 | 111 | |
michael@0 | 112 | test(); |