Sat, 03 Jan 2015 20:18:00 +0100
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 | // This file was written by Andy Wingo <wingo@igalia.com> and originally |
michael@0 | 2 | // contributed to V8 as generators-objects.js, available here: |
michael@0 | 3 | // |
michael@0 | 4 | // http://code.google.com/p/v8/source/browse/branches/bleeding_edge/test/mjsunit/harmony/generators-objects.js |
michael@0 | 5 | |
michael@0 | 6 | // Test aspects of the generator runtime. |
michael@0 | 7 | |
michael@0 | 8 | // Test the properties and prototype of a generator object. |
michael@0 | 9 | function TestGeneratorObject() { |
michael@0 | 10 | function* g() { yield 1; } |
michael@0 | 11 | |
michael@0 | 12 | var iter = g(); |
michael@0 | 13 | assertEq(Object.getPrototypeOf(iter), g.prototype); |
michael@0 | 14 | assertTrue(iter instanceof g); |
michael@0 | 15 | assertEq(String(iter), "[object Generator]"); |
michael@0 | 16 | assertDeepEq(Object.getOwnPropertyNames(iter), []); |
michael@0 | 17 | assertNotEq(g(), iter); |
michael@0 | 18 | |
michael@0 | 19 | // g() is the same as new g(). |
michael@0 | 20 | iter = new g(); |
michael@0 | 21 | assertEq(Object.getPrototypeOf(iter), g.prototype); |
michael@0 | 22 | assertTrue(iter instanceof g); |
michael@0 | 23 | assertEq(String(iter), "[object Generator]"); |
michael@0 | 24 | assertDeepEq(Object.getOwnPropertyNames(iter), []); |
michael@0 | 25 | assertNotEq(new g(), iter); |
michael@0 | 26 | } |
michael@0 | 27 | TestGeneratorObject(); |
michael@0 | 28 | |
michael@0 | 29 | |
michael@0 | 30 | // Test the methods of generator objects. |
michael@0 | 31 | function TestGeneratorObjectMethods() { |
michael@0 | 32 | function* g() { yield 1; } |
michael@0 | 33 | var iter = g(); |
michael@0 | 34 | |
michael@0 | 35 | function TestNonGenerator(non_generator) { |
michael@0 | 36 | assertThrowsInstanceOf(function() { iter.next.call(non_generator); }, TypeError); |
michael@0 | 37 | assertThrowsInstanceOf(function() { iter.next.call(non_generator, 1); }, TypeError); |
michael@0 | 38 | assertThrowsInstanceOf(function() { iter.throw.call(non_generator, 1); }, TypeError); |
michael@0 | 39 | assertThrowsInstanceOf(function() { iter.close.call(non_generator); }, TypeError); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | TestNonGenerator(1); |
michael@0 | 43 | TestNonGenerator({}); |
michael@0 | 44 | TestNonGenerator(function(){}); |
michael@0 | 45 | TestNonGenerator(g); |
michael@0 | 46 | TestNonGenerator(g.prototype); |
michael@0 | 47 | } |
michael@0 | 48 | TestGeneratorObjectMethods(); |
michael@0 | 49 | |
michael@0 | 50 | |
michael@0 | 51 | if (typeof reportCompare == "function") |
michael@0 | 52 | reportCompare(true, true); |