/
test_bindings.js
196 lines (180 loc) · 5.52 KB
/
test_bindings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
//window.alert(ClientRect);
//window.alert(ClientRectList);
window.alert(window);
var document = window.document;
window.alert("==1==");
window.alert(document.documentElement);
window.alert(document.documentElement.firstChild);
window.alert(document.documentElement.nextSibling);
window.alert(document instanceof HTMLDocument);
window.alert(document instanceof Document);
var elems = document.getElementsByTagName('div');
window.alert(elems.length);
let elem = elems[0];
window.alert(elem.nodeType);
window.alert(elem);
window.alert("==1.5==");
var rect = elem.getBoundingClientRect();
window.alert(rect);
window.alert(rect.top);
window.alert(rect.bottom);
window.alert(rect.left);
window.alert(rect.right);
window.alert(rect.width);
window.alert(rect.height);
window.alert("==2==");
var rects = elem.getClientRects();
window.alert("==3==");
window.alert(rects);
window.alert(rects.length);
window.alert("==4==");
let rect = rects[0];
window.alert(rect);
/*window.alert(Object.prototype.toString.call(rect.__proto__));
window.alert(rect.__proto__ === Object.getPrototypeOf(rect));
window.alert(rect.__proto__.top);
window.alert(Object.getPrototypeOf(rect).top);*/
window.alert(rect.top);
window.alert(rect.bottom);
window.alert(rect.left);
window.alert(rect.right);
window.alert(rect.width);
window.alert(rect.height);
window.alert("HTMLCollection:");
let tags = document.getElementsByTagName("div");
//let tag = tags[0];
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0]);
window.alert(tags[0].tagName);
window.alert(tags[0].getClientRects());
window.alert(tags[1]);
window.alert(tags[2]);
window.alert(tags[3]);
let tags = document.getElementsByName("test");
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0]);
window.alert(tags[0].tagName);
window.alert(tags[1]);
window.alert(tags[1].tagName);
window.alert(tags[2]);
let tags = document.links;
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0]);
window.alert(tags[0].tagName);
let tags = document.images;
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0]);
window.alert(tags[0].tagName);
let tags = document.embeds;
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0]);
window.alert(tags[0].tagName);
let tags = document.plugins;
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0]);
window.alert(tags[0].tagName);
let tags = document.forms;
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0]);
window.alert(tags[0].tagName);
let tags = document.scripts;
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0]);
window.alert(tags[0].tagName);
let tags = document.applets;
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0]);
window.alert(tags[0].tagName);
window.alert("Document:");
let head = document.head;
window.alert(head);
window.alert(head.tagName);
window.alert("DOMParser:");
window.alert(DOMParser);
let parser = new DOMParser();
window.alert(parser);
//window.alert(parser.parseFromString("<html></html>", "text/html"));
window.alert("Event:");
window.alert(Event);
let ev = new Event("foopy");
window.alert(ev.type);
window.alert(ev.defaultPrevented);
ev.preventDefault();
window.alert(ev.defaultPrevented);
window.alert("MouseEvent:");
window.alert(MouseEvent);
let ev2 = new MouseEvent("press", {bubbles: true, screenX: 150, detail: 100});
window.alert(ev2);
window.alert(ev2.screenX);
window.alert(ev2.detail);
window.alert(ev2.getModifierState("ctrl"));
window.alert(ev2 instanceof Event);
window.alert(ev2 instanceof UIEvent);
window.alert(document.title);
document.title = "foo";
window.alert(document.title);
window.alert(document.links[0]);
window.alert(document.getElementsByTagName('iframe')[0]);
window.alert(document.getElementsByTagName("body")[0]);
window.alert("OList:");
let tags = document.getElementsByTagName("ol");
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0]);
window.alert(tags[0].tagName);
window.alert("HTMLElement:");
let tagList = ["section", "aside", "b", "i"];
for (let i = 0, l = tagList.length; i < l; ++i) {
let tags = document.getElementsByTagName(tagList[i]);
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0].tagName);
window.alert(tags[0] instanceof HTMLElement);
}
window.alert("HTMLCanvasElement:");
let tags = document.getElementsByTagName("canvas");
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0].tagName);
window.alert(tags[0] instanceof HTMLCanvasElement);
window.alert("HTMLSourceElement:");
let tags = document.getElementsByTagName("source");
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0].tagName);
window.alert(tags[0] instanceof HTMLSourceElement);
window.alert("HTMLTimeElement:");
let tags = document.getElementsByTagName("time");
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0].tagName);
window.alert(tags[0] instanceof HTMLTimeElement);
window.alert("HTMLTableCaptionElement:");
let tags = document.getElementsByTagName("caption");
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0].tagName);
window.alert(tags[0] instanceof HTMLTableCaptionElement);
window.alert("HTMLTextAreaElement:");
let tags = document.getElementsByTagName("textarea");
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0].tagName);
window.alert(tags[0] instanceof HTMLTextAreaElement);
//TODO: Doesn't work until we throw proper exceptions instead of returning 0 on
// unwrap failure.
/*try {
Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rects), "length").get.call(window);
window.alert("hmm?");
} catch (x) {
window.alert("ok");
}*/