Rebaseline some tests after r169260
[WebKit-https.git] / LayoutTests / js / dom / script-tests / delete-syntax.js
1 description(
2 "This test checks whether various forms of delete expression are allowed."
3 );
4
5 window.y = 0;
6
7 shouldBeTrue('delete x');
8 window.x = 0;
9 window.y = 0;
10 shouldBeTrue('delete window.x');
11 window.x = 0;
12 window.y = 0;
13 shouldBeTrue('delete window["x"]');
14 window.x = 0;
15 window.y = 0;
16 shouldBeTrue('delete (x)');
17 window.x = 0;
18 window.y = 0;
19 shouldBeTrue('delete (window.x)');
20 window.x = 0;
21 window.y = 0;
22 shouldBeTrue('delete (window["x"])');
23 window.x = 0;
24 window.y = 0;
25 shouldBeTrue('(y, delete x)');
26 window.x = 0;
27 window.y = 0;
28 shouldBeTrue('delete ((x))');
29 window.x = 0;
30 window.y = 0;
31 shouldBeTrue('delete ((window.x))');
32 window.x = 0;
33 window.y = 0;
34 shouldBeTrue('delete ((window["x"]))');
35 window.x = 0;
36 window.y = 0;
37 shouldBeTrue('delete (y, x)');
38 window.x = 0;
39 window.y = 0;
40 shouldBeTrue('delete (true ? x : y)');
41 window.x = 0;
42 window.y = 0;
43
44 shouldBeTrue('delete nonexistent');
45 shouldBeTrue('delete window.nonexistent');
46 shouldBeTrue('delete window["nonexistent"]');
47 shouldBeTrue('delete (nonexistent)');
48 shouldBeTrue('delete (window.nonexistent)');
49 shouldBeTrue('delete (window["nonexistent"])');
50
51 shouldBeTrue('delete "x"');
52 shouldBeTrue('delete (2 + 3)');
53
54 var mathCos = Math.cos;
55 delete Math.sin;
56 Math.tan = null;
57 // Try deleting & overwriting static properties.
58 shouldBe("Math.cos", "mathCos");
59 shouldBe("Math.sin", "undefined");
60 shouldBe("Math.tan", "null");
61
62 var regExpPrototypeCompile = RegExp.prototype.compile;
63 RegExp.prototype.test = null;
64 Object.preventExtensions(RegExp.prototype);
65 delete RegExp.prototype.exec;
66 // Reverse order of delete & overwrite, tests delete after preventExtensions.
67 shouldBe("RegExp.prototype.compile", "regExpPrototypeCompile");
68 shouldBe("RegExp.prototype.exec", "undefined");
69 shouldBe("RegExp.prototype.test", "null");
70
71 // Check that once a property is deleted its name is removed from the property name array.
72 delete Object.prototype.__defineSetter__;
73 shouldBe("Object.getOwnPropertyNames(Object.prototype).indexOf('__defineSetter__')", "-1");
74
75 delete navigator.appCodeName;
76 var navigatorPropertyNames = Object.getOwnPropertyNames(navigator);
77 var expectedPropertyNames = [
78     "appName",
79     "appVersion",
80     "language",
81     "userAgent",
82     "platform",
83     "plugins",
84     "mimeTypes",
85     "product",
86     "productSub",
87     "vendor",
88     "vendorSub",
89     "cookieEnabled",
90     "onLine"
91 ];
92
93 for (var i = 0; i < expectedPropertyNames.length; ++i)
94     shouldBeTrue("navigatorPropertyNames.indexOf('" + expectedPropertyNames[i] +"') != -1");
95 var navigatorPrototypePropertyNames = Object.getOwnPropertyNames(navigator.__proto__);
96 for (var i = 0; i < expectedPropertyNames.length; ++i)
97     shouldBeTrue("navigatorPrototypePropertyNames.indexOf('" + expectedPropertyNames[i] +"') == -1");