js/src/tests/ecma_3_1/Object/regress-444787.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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 var BUGNUMBER = 444787;
michael@0 8 var summary = 'Object.getPrototypeOf';
michael@0 9 var actual = '';
michael@0 10 var expect = '';
michael@0 11
michael@0 12
michael@0 13 //-----------------------------------------------------------------------------
michael@0 14 test();
michael@0 15 //-----------------------------------------------------------------------------
michael@0 16
michael@0 17 function test()
michael@0 18 {
michael@0 19 enterFunc ('test');
michael@0 20 printBugNumber(BUGNUMBER);
michael@0 21 printStatus (summary);
michael@0 22
michael@0 23 var i;
michael@0 24 var type;
michael@0 25 var instance;
michael@0 26 var types = [
michael@0 27 Array,
michael@0 28 Boolean,
michael@0 29 Date,
michael@0 30 Error,
michael@0 31 Function,
michael@0 32 Math,
michael@0 33 Number,
michael@0 34 Object,
michael@0 35 RegExp,
michael@0 36 String,
michael@0 37 ];
michael@0 38
michael@0 39 for (i = 0; i < types.length; i++)
michael@0 40 {
michael@0 41 type = types[i];
michael@0 42
michael@0 43 if (typeof type.__proto__ != 'undefined')
michael@0 44 {
michael@0 45 expect = type.__proto__;
michael@0 46 actual = Object.getPrototypeOf(type);
michael@0 47 reportCompare(expect, actual, summary + ': ' + type.name);
michael@0 48 }
michael@0 49
michael@0 50 try
michael@0 51 {
michael@0 52 eval('instance = new ' + type.name);
michael@0 53 expect = type.prototype;
michael@0 54 actual = Object.getPrototypeOf(instance);
michael@0 55 reportCompare(expect, actual, summary + ': new ' + type.name);
michael@0 56 }
michael@0 57 catch(ex if ex instanceof TypeError)
michael@0 58 {
michael@0 59 print('Ignore ' + ex);
michael@0 60 }
michael@0 61 catch(ex)
michael@0 62 {
michael@0 63 actual = ex + '';
michael@0 64 reportCompare(expect, actual, summary + ': new ' + type.name);
michael@0 65 }
michael@0 66
michael@0 67 }
michael@0 68
michael@0 69 types = [null, undefined];
michael@0 70
michael@0 71 for (i = 0; i < types.length; i++)
michael@0 72 {
michael@0 73 type = types[i];
michael@0 74 expect = 'TypeError: Object.getPrototype is not a function';
michael@0 75 try
michael@0 76 {
michael@0 77 actual = Object.getPrototype(null);
michael@0 78 }
michael@0 79 catch(ex)
michael@0 80 {
michael@0 81 actual = ex + '';
michael@0 82 }
michael@0 83 reportCompare(expect, actual, summary + ': ' + type);
michael@0 84 }
michael@0 85
michael@0 86 var objects = [
michael@0 87 {instance: [0], type: Array},
michael@0 88 {instance: (function () {}), type: Function},
michael@0 89 {instance: eval, type: Function},
michael@0 90 {instance: parseInt, type: Function},
michael@0 91 {instance: {a: ''}, type: Object},
michael@0 92 {instance: /foo/, type: RegExp}
michael@0 93 ];
michael@0 94
michael@0 95 for (i = 0; i < objects.length; i++)
michael@0 96 {
michael@0 97 instance = objects[i].instance;
michael@0 98 type = objects[i].type;
michael@0 99 expect = type.prototype;
michael@0 100 actual = Object.getPrototypeOf(instance);
michael@0 101 reportCompare(expect, actual, summary + ' instance: ' + instance + ', type: ' + type.name);
michael@0 102 }
michael@0 103
michael@0 104 var non_objects = [ true, false, 1.0, Infinity, NaN, Math.PI, "bar" ];
michael@0 105
michael@0 106 for (i = 0; i < non_objects.length; i++)
michael@0 107 {
michael@0 108 instance = non_objects[i];
michael@0 109 expect = 'TypeError: instance is not an object';
michael@0 110 try
michael@0 111 {
michael@0 112 actual = Object.getPrototypeOf(instance);
michael@0 113 }
michael@0 114 catch(ex)
michael@0 115 {
michael@0 116 actual = ex + '';
michael@0 117 }
michael@0 118 reportCompare(expect, actual, summary + ' non-object: ' + actual);
michael@0 119 }
michael@0 120
michael@0 121 exitFunc ('test');
michael@0 122 }

mercurial