js/src/tests/js1_7/extensions/iterator-ctor.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 // See http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Iterators_and_Generators
michael@0 7
michael@0 8 //-----------------------------------------------------------------------------
michael@0 9 var BUGNUMBER = "410725";
michael@0 10 var summary = "Test of the global Iterator constructor";
michael@0 11 var actual, expect;
michael@0 12
michael@0 13 printBugNumber(BUGNUMBER);
michael@0 14 printStatus(summary);
michael@0 15
michael@0 16 /**************
michael@0 17 * BEGIN TEST *
michael@0 18 **************/
michael@0 19
michael@0 20 function iteratorToArray(iterator) {
michael@0 21 var result = [];
michael@0 22 for (var i in iterator) {
michael@0 23 result[result.length] = i;
michael@0 24 }
michael@0 25 return result.sort();
michael@0 26 }
michael@0 27
michael@0 28 var obj = {a:1, b:2};
michael@0 29
michael@0 30 reportCompare('["a", "b"]',
michael@0 31 uneval(iteratorToArray(obj)),
michael@0 32 'uneval(iteratorToArray(obj))');
michael@0 33
michael@0 34 reportCompare('[["a", 1], ["b", 2]]',
michael@0 35 uneval(iteratorToArray(Iterator(obj))),
michael@0 36 'uneval(iteratorToArray(Iterator(obj)))');
michael@0 37
michael@0 38 reportCompare('[["a", 1], ["b", 2]]',
michael@0 39 uneval(iteratorToArray(new Iterator(obj))),
michael@0 40 'uneval(iteratorToArray(new Iterator(obj)))');
michael@0 41
michael@0 42 reportCompare('[["a", 1], ["b", 2]]',
michael@0 43 uneval(iteratorToArray(Iterator(obj,false))),
michael@0 44 'uneval(iteratorToArray(Iterator(obj,false)))');
michael@0 45
michael@0 46 reportCompare('[["a", 1], ["b", 2]]',
michael@0 47 uneval(iteratorToArray(new Iterator(obj,false))),
michael@0 48 'uneval(iteratorToArray(new Iterator(obj,false)))');
michael@0 49
michael@0 50 reportCompare('["a", "b"]',
michael@0 51 uneval(iteratorToArray(Iterator(obj,true))),
michael@0 52 'uneval(iteratorToArray(Iterator(obj,true)))');
michael@0 53
michael@0 54 reportCompare('["a", "b"]',
michael@0 55 uneval(iteratorToArray(new Iterator(obj,true))),
michael@0 56 'uneval(iteratorToArray(new Iterator(obj,true)))');
michael@0 57
michael@0 58 var flag;
michael@0 59 var obji = {a:1, b:2};
michael@0 60 obji.__iterator__ = function (b) { flag = b; yield -1; yield -2; }
michael@0 61
michael@0 62 flag = -1;
michael@0 63 reportCompare('[-1, -2]',
michael@0 64 uneval(iteratorToArray(obji)),
michael@0 65 'uneval(iteratorToArray(obji))');
michael@0 66 reportCompare(true, flag, 'uneval(iteratorToArray(obji)) flag');
michael@0 67
michael@0 68 flag = -1;
michael@0 69 reportCompare('[-1, -2]',
michael@0 70 uneval(iteratorToArray(Iterator(obji))),
michael@0 71 'uneval(iteratorToArray(Iterator(obji)))');
michael@0 72 reportCompare(false, flag, 'uneval(iteratorToArray(Iterator(obji))) flag');
michael@0 73
michael@0 74 flag = -1;
michael@0 75 reportCompare('[-1, -2]',
michael@0 76 uneval(iteratorToArray(new Iterator(obji))),
michael@0 77 'uneval(iteratorToArray(new Iterator(obji)))');
michael@0 78 reportCompare(false, flag, 'uneval(iteratorToArray(new Iterator(obji))) flag');
michael@0 79
michael@0 80 flag = -1;
michael@0 81 reportCompare('[-1, -2]',
michael@0 82 uneval(iteratorToArray(Iterator(obji,false))),
michael@0 83 'uneval(iteratorToArray(Iterator(obji,false)))');
michael@0 84 reportCompare(false, flag, 'uneval(iteratorToArray(Iterator(obji,false))) flag');
michael@0 85
michael@0 86 flag = -1;
michael@0 87 reportCompare('[-1, -2]',
michael@0 88 uneval(iteratorToArray(new Iterator(obji,false))),
michael@0 89 'uneval(iteratorToArray(new Iterator(obji,false)))');
michael@0 90 reportCompare(false, flag, 'uneval(iteratorToArray(new Iterator(obji,false))) flag');
michael@0 91
michael@0 92 flag = -1;
michael@0 93 reportCompare('[-1, -2]',
michael@0 94 uneval(iteratorToArray(Iterator(obji,true))),
michael@0 95 'uneval(iteratorToArray(Iterator(obji,true)))');
michael@0 96 reportCompare(true, flag, 'uneval(iteratorToArray(Iterator(obji,true))) flag');
michael@0 97
michael@0 98 flag = -1;
michael@0 99 reportCompare('[-1, -2]',
michael@0 100 uneval(iteratorToArray(new Iterator(obji,true))),
michael@0 101 'uneval(iteratorToArray(new Iterator(obji,true)))');
michael@0 102 reportCompare(true, flag, 'uneval(iteratorToArray(new Iterator(obji,true))) flag');

mercurial