OLD | NEW |
1 description("Test what happens when you set the window's prototype to various va
lues."); | 1 description("Test what happens when you set the window's prototype to various va
lues."); |
2 | 2 |
3 var originalWindowPrototype = __proto__; | 3 var originalWindowPrototype = __proto__; |
4 var chainPointingBackToWindow = { __proto__: window }; | 4 var chainPointingBackToWindow = { __proto__: window }; |
5 var anotherObject = { }; | 5 var anotherObject = { }; |
| 6 var error = "'TypeError: Immutable prototype object \\'#<Window>\\' cannot have
their prototype set'"; |
6 | 7 |
7 shouldThrow("__proto__ = window; __proto", "'TypeError: Cyclic __proto__ value'"
); | 8 shouldThrow("__proto__ = window; __proto__", error); |
8 shouldThrow("__proto__ = chainPointingBackToWindow; __proto__", "'TypeError: Cyc
lic __proto__ value'"); | 9 shouldThrow("__proto__ = chainPointingBackToWindow; __proto__", error); |
9 shouldBe("__proto__ = 1; __proto__", "originalWindowPrototype"); | 10 shouldBe("__proto__ = 1; __proto__", "originalWindowPrototype"); |
10 shouldBe("__proto__ = 'a string'; __proto__", "originalWindowPrototype"); | 11 shouldBe("__proto__ = 'a string'; __proto__", "originalWindowPrototype"); |
11 shouldBe("__proto__ = anotherObject; __proto__", "anotherObject"); | 12 shouldThrow("__proto__ = anotherObject; __proto__", error); |
12 shouldThrow("anotherObject.__proto__ = window; __proto__", "'TypeError: Cyclic _
_proto__ value'"); | 13 shouldBe("anotherObject.__proto__ = window; __proto__", "originalWindowPrototype
"); |
13 shouldBe("__proto__ = 1; __proto__", "anotherObject"); | 14 shouldBe("__proto__ = 1; __proto__", "originalWindowPrototype"); |
14 shouldBe("__proto__ = 'a string'; __proto__", "anotherObject"); | 15 shouldBe("__proto__ = 'a string'; __proto__", "originalWindowPrototype"); |
15 shouldBe("__proto__ = anotherObject; __proto__", "anotherObject"); | 16 shouldThrow("__proto__ = anotherObject; __proto__", error); |
16 shouldBe("__proto__ = originalWindowPrototype; __proto__", "originalWindowProtot
ype"); | 17 shouldBe("__proto__ = originalWindowPrototype; __proto__", "originalWindowProtot
ype"); |
17 shouldBe("anotherObject.__proto__ = window; anotherObject.__proto__", "window"); | 18 shouldBe("anotherObject.__proto__ = window; anotherObject.__proto__", "window"); |
18 shouldBe("__proto__ = null; window.__proto__", "undefined"); | 19 shouldThrow("__proto__ = null; __proto__", error); |
| 20 shouldThrow("location.__proto__.__proto__ = location", "'TypeError: Cyclic __pro
to__ value'"); |
OLD | NEW |