2 This page tests var declarations that attempt to shadow interesting global properties in
3 interesting ways.
<a href=
"http://bugs.webkit.org/show_bug.cgi?id=16644">Bug
16644</a>.
7 If the test passes, you'll see a series of PASS messages below.
10 <pre id=
"console"></pre>
13 if (window
.testRunner
)
14 testRunner
.dumpAsText();
18 document
.getElementById("console").appendChild(document
.createTextNode(s
+ "\n"));
21 function shouldBe(a
, aDescription
, b
)
24 log("PASS: " + aDescription
+ " should be " + b
+ " and is.");
26 log("FAIL: " + aDescription
+ " should be " + b
+ " but instead is " + a
+ ".");
32 var Node
; // shadow existing property of the global object
33 eval("var Element;"); // ditto, but using eval
35 var toString
; // shadow existing property of the global object's prototype
36 eval("var valueOf;"); // ditto, but using eval
38 shouldBe(Node
== undefined, "Node == undefined", false);
39 shouldBe(eval('Node == undefined'), "eval('Node == undefined')", false);
41 shouldBe(Element
== undefined, "Element == undefined", false);
42 shouldBe(eval('Element == undefined'), "eval('Element == undefined')", false);
44 shouldBe(toString
== undefined, "toString == undefined", false);
45 shouldBe(eval('toString == undefined'), "eval('toString == undefined')", false);
47 shouldBe(valueOf
== undefined, "valueOf == undefined", false);
48 shouldBe(eval('valueOf == undefined'), "eval('valueOf == undefined')", false);
52 // Repeat the tests above, this time explicitly overwriting existing properties
54 var HTMLElement
= marker
;
55 eval("var HTMLLinkElement = marker;");
58 eval("var find = marker;");
60 shouldBe(HTMLElement
== marker
, "HTMLElement == marker", true);
61 shouldBe(eval('HTMLElement == marker'), "eval('HTMLElement == marker')", true);
63 shouldBe(HTMLLinkElement
== marker
, "HTMLLinkElement == marker", true);
64 shouldBe(eval('HTMLLinkElement == marker'), "eval('HTMLLinkElement == marker')", true);
66 shouldBe(moveBy
== marker
, "moveBy == marker", true);
67 shouldBe(eval('moveBy == marker'), "eval('moveBy == marker')", true);
69 shouldBe(find
== marker
, "find == marker", true);
70 shouldBe(eval('find == marker'), "eval('find == marker')", true);
74 // Various variable names that are, or at one point were, unsettable in WebKit.
77 eval("var locationbar = marker");
79 shouldBe(locationbar
== marker
, "locationbar == marker", true);
80 shouldBe(eval('locationbar == marker'), "eval('locationbar == marker')", true);
83 eval("var menubar = marker");
85 shouldBe(menubar
== marker
, "menubar == marker", true);
86 shouldBe(eval('menubar == marker'), "eval('menubar == marker')", true);
89 eval("var personalbar = marker");
91 shouldBe(personalbar
== marker
, "personalbar == marker", true);
92 shouldBe(eval('personalbar == marker'), "eval('personalbar == marker')", true);
95 eval("var scrollbars = marker");
97 shouldBe(scrollbars
== marker
, "scrollbars == marker", true);
98 shouldBe(eval('scrollbars == marker'), "eval('scrollbars == marker')", true);
101 eval("var statusbar = marker");
103 shouldBe(statusbar
== marker
, "statusbar == marker", true);
104 shouldBe(eval('statusbar == marker'), "eval('statusbar == marker')", true);
107 eval("var toolbar = marker");
109 shouldBe(toolbar
== marker
, "toolbar == marker", true);
110 shouldBe(eval('toolbar == marker'), "eval('toolbar == marker')", true);
113 eval("var offscreenBuffering = marker");
115 shouldBe(offscreenBuffering
== marker
, "offscreenBuffering == marker", true);
116 shouldBe(eval('offscreenBuffering == marker'), "eval('offscreenBuffering == marker')", true);
119 eval("var outerHeight = marker");
121 shouldBe(outerHeight
== marker
, "outerHeight == marker", true);
122 shouldBe(eval('outerHeight == marker'), "eval('outerHeight == marker')", true);
125 eval("var outerWidth = marker");
127 shouldBe(outerWidth
== marker
, "outerWidth == marker", true);
128 shouldBe(eval('outerWidth == marker'), "eval('outerWidth == marker')", true);
131 eval("var innerHeight = marker");
133 shouldBe(innerHeight
== marker
, "innerHeight == marker", true);
134 shouldBe(eval('innerHeight == marker'), "eval('innerHeight == marker')", true);
137 eval("var innerWidth = marker");
139 shouldBe(innerWidth
== marker
, "innerWidth == marker", true);
140 shouldBe(eval('innerWidth == marker'), "eval('innerWidth == marker')", true);
143 eval("var screenX = marker");
145 shouldBe(screenX
== marker
, "screenX == marker", true);
146 shouldBe(eval('screenX == marker'), "eval('screenX == marker')", true);
149 eval("var screenY = marker");
151 shouldBe(screenY
== marker
, "screenY == marker", true);
152 shouldBe(eval('screenY == marker'), "eval('screenY == marker')", true);
155 eval("var screenLeft = marker");
157 shouldBe(screenLeft
== marker
, "screenLeft == marker", true);
158 shouldBe(eval('screenLeft == marker'), "eval('screenLeft == marker')", true);
161 eval("var screenTop = marker");
163 shouldBe(screenTop
== marker
, "screenTop == marker", true);
164 shouldBe(eval('screenTop == marker'), "eval('screenTop == marker')", true);
167 eval("var scrollX = marker");
169 shouldBe(scrollX
== marker
, "scrollX == marker", true);
170 shouldBe(eval('scrollX == marker'), "eval('scrollX == marker')", true);
173 eval("var scrollY = marker");
175 shouldBe(scrollY
== marker
, "scrollY == marker", true);
176 shouldBe(eval('scrollY == marker'), "eval('scrollY == marker')", true);
179 eval("var length = marker");
181 shouldBe(length
== marker
, "length == marker", true);
182 shouldBe(eval('length == marker'), "eval('length == marker')", true);
185 eval("var self = marker");
187 shouldBe(self
== marker
, "self == marker", true);
188 shouldBe(eval('self == marker'), "eval('self == marker')", true);
191 eval("var frames = marker");
193 shouldBe(frames
== marker
, "frames == marker", true);
194 shouldBe(eval('frames == marker'), "eval('frames == marker')", true);
197 eval("var opener = marker");
199 shouldBe(opener
== marker
, "opener == marker", true);
200 shouldBe(eval('opener == marker'), "eval('opener == marker')", true);
203 eval("var parent = marker");
205 shouldBe(parent
== marker
, "parent == marker", true);
206 shouldBe(eval('parent == marker'), "eval('parent == marker')", true);
209 eval("var devicePixelRatio = marker");
211 shouldBe(devicePixelRatio
== marker
, "devicePixelRatio == marker", true);
212 shouldBe(eval('devicePixelRatio == marker'), "eval('devicePixelRatio == marker')", true);
215 eval("var devicePixelRatio = marker");
217 shouldBe(devicePixelRatio
== marker
, "devicePixelRatio == marker", true);
218 shouldBe(eval('devicePixelRatio == marker'), "eval('devicePixelRatio == marker')", true);
221 eval("var navigator = marker");
223 shouldBe(navigator
== marker
, "navigator == marker", false);
224 shouldBe(eval('navigator == marker'), "eval('navigator == marker')", false);
227 eval("var clientInformation = marker");
229 shouldBe(clientInformation
== marker
, "clientInformation == marker", true);
230 shouldBe(eval('clientInformation == marker'), "eval('clientInformation == marker')", true);
233 eval("var status = marker");
235 shouldBe(status
== marker
, "status == marker", true);
236 shouldBe(eval('status == marker'), "eval('status == marker')", true);
239 eval("var defaultStatus = marker");
241 shouldBe(defaultStatus
== marker
, "defaultStatus == marker", true);
242 shouldBe(eval('defaultStatus == marker'), "eval('defaultStatus == marker')", true);
245 eval("var defaultstatus = marker");
247 shouldBe(defaultstatus
== marker
, "defaultstatus == marker", true);
248 shouldBe(eval('defaultstatus == marker'), "eval('defaultstatus == marker')", true);
251 eval("var screen = marker");
253 shouldBe(screen
== marker
, "screen == marker", true);
254 shouldBe(eval('screen == marker'), "eval('screen == marker')", true);
257 eval("var history = marker");
259 shouldBe(history
== marker
, "history == marker", false);
260 shouldBe(eval('history == marker'), "eval('history == marker')", false);
265 eval("var frameElement = marker");
267 shouldBe(frameElement
== marker
, "frameElement == marker", false);
268 shouldBe(eval('frameElement == marker'), "eval('frameElement == marker')", false);
271 eval("var pageXOffset = marker");
273 shouldBe(pageXOffset
== marker
, "pageXOffset == marker", true);
274 shouldBe(eval('pageXOffset == marker'), "eval('pageXOffset == marker')", true);
277 eval("var pageYOffset = marker");
279 shouldBe(pageYOffset
== marker
, "pageYOffset == marker", true);
280 shouldBe(eval('pageYOffset == marker'), "eval('pageYOffset == marker')", true);
283 eval("var closed = marker");
285 shouldBe(closed
== marker
, "closed == marker", false);
286 shouldBe(eval('closed == marker'), "eval('closed == marker')", false);
289 eval("var window = marker");
291 shouldBe(window
== marker
, "window == marker", false);
292 shouldBe(eval('window == marker'), "eval('window == marker')", false);
295 eval("var document = marker");
297 shouldBe(document
== marker
, "document == marker", false);
298 shouldBe(eval('document == marker'), "eval('document == marker')", false);
301 eval("var crypto = marker");
303 shouldBe(crypto
== marker
, "crypto == marker", false);
304 shouldBe(eval('crypto == marker'), "eval('crypto == marker')", false);
307 eval("var top = marker");
309 shouldBe(top
== marker
, "top == marker", false);
310 shouldBe(eval('top == marker'), "eval('top == marker')", false);