Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / security / cross-frame-access-getOwnPropertyDescriptor.html
1 <html>
2 <head>
3     <script src="resources/cross-frame-access.js"></script>
4     <script>
5         var windowConstructorPropertiesNotAllowed = [
6             "Attr", 
7             "Audio",
8             "CDATASection", 
9             "CSSPrimitiveValue", 
10             "CSSRule", 
11             "CSSStyleDeclaration", 
12             "CSSValue", 
13             "CharacterData", 
14             "Comment", 
15             "DOMException", 
16             "DOMImplementation", 
17             "DOMParser", 
18             "Document", 
19             "DocumentFragment", 
20             "DocumentType", 
21             "Element", 
22             "EntityReference", 
23             "EvalError", 
24             "Event", 
25             "HTMLAnchorElement", 
26             "HTMLAudioElement", 
27             "HTMLAppletElement", 
28             "HTMLAreaElement", 
29             "HTMLBRElement", 
30             "HTMLBaseElement", 
31             "HTMLBodyElement", 
32             "HTMLButtonElement", 
33             "HTMLCanvasElement", 
34             "HTMLDListElement", 
35             "HTMLDirectoryElement", 
36             "HTMLDivElement", 
37             "HTMLDocument", 
38             "HTMLElement", 
39             "HTMLFieldSetElement", 
40             "HTMLFontElement", 
41             "HTMLFormElement", 
42             "HTMLFrameElement", 
43             "HTMLFrameSetElement", 
44             "HTMLHRElement", 
45             "HTMLHeadElement", 
46             "HTMLHeadingElement", 
47             "HTMLHtmlElement", 
48             "HTMLIFrameElement", 
49             "HTMLImageElement", 
50             "HTMLInputElement", 
51             "HTMLIsIndexElement", 
52             "HTMLLIElement", 
53             "HTMLLabelElement", 
54             "HTMLLegendElement", 
55             "HTMLLinkElement", 
56             "HTMLMapElement", 
57             "HTMLMarqueeElement", 
58             "HTMLMediaElement", 
59             "HTMLMenuElement", 
60             "HTMLMetaElement", 
61             "HTMLModElement", 
62             "HTMLOListElement", 
63             "HTMLOptGroupElement", 
64             "HTMLOptionElement", 
65             "HTMLParagraphElement", 
66             "HTMLParamElement", 
67             "HTMLPreElement", 
68             "HTMLQuoteElement", 
69             "HTMLScriptElement", 
70             "HTMLSelectElement", 
71             "HTMLSourceElement",  
72             "HTMLStyleElement", 
73             "HTMLTableCaptionElement", 
74             "HTMLTableCellElement", 
75             "HTMLTableColElement", 
76             "HTMLTableElement", 
77             "HTMLTableRowElement", 
78             "HTMLTableSectionElement", 
79             "HTMLTextAreaElement", 
80             "HTMLTitleElement", 
81             "HTMLUListElement", 
82             "HTMLVideoElement", 
83             "Image", 
84             "MutationEvent", 
85             "Node", 
86             "NodeFilter", 
87             "Notation", 
88             "Option", 
89             "ProcessingInstruction", 
90             "Range", 
91             "RangeError", 
92             "ReferenceError", 
93             "SyntaxError", 
94             "Text", 
95             "TypeError", 
96             "URIError", 
97             "XMLDocument", 
98             "XMLHttpRequest", 
99             "XMLSerializer", 
100             "XPathEvaluator", 
101             "XPathResult", 
102             "XSLTProcessor"
103         ];
104
105         var windowFunctionPropertiesNotAllowed = [
106             "addEventListener", 
107             "alert", 
108             "atob",
109             "btoa", 
110             "captureEvents",
111             "clearInterval", 
112             "clearTimeout", 
113             "confirm",
114             "find", 
115             "getComputedStyle",
116             "getMatchedCSSRules", 
117             "getSelection", 
118             "moveBy", 
119             "moveTo", 
120             "open", 
121             "print", 
122             "prompt", 
123             "releaseEvents",
124             "removeEventListener", 
125             "resizeBy", 
126             "resizeTo", 
127             "scroll", 
128             "scrollBy", 
129             "scrollTo", 
130             "setInterval", 
131             "setTimeout", 
132             "showModalDialog", 
133             "stop",
134             "blur",
135             "close",
136             "focus"
137         ];
138
139         var windowAttributesPropertiesNotAllowed = [
140             "clientInformation", 
141             "console", 
142             "crypto", 
143             "defaultStatus", 
144             "defaultstatus", 
145             "devicePixelRatio", 
146             "document",
147             "embeds",
148             "eval",
149             "event", 
150             "frameElement", 
151             "images",
152             "innerHeight", 
153             "innerWidth", 
154             "locationbar", 
155             "menubar", 
156             "name", 
157             "navigator", 
158             "offscreenBuffering", 
159             "onabort", 
160             "onbeforeunload", 
161             "onblur", 
162             "onchange", 
163             "onclick", 
164             "ondblclick", 
165             "onerror", 
166             "onfocus", 
167             "onkeydown", 
168             "onkeypress", 
169             "onkeyup", 
170             "onload", 
171             "onmousedown", 
172             "onmousemove", 
173             "onmouseout", 
174             "onmouseover", 
175             "onmouseup", 
176             "onmousewheel", 
177             "onreset", 
178             "onresize", 
179             "onscroll", 
180             "onsearch", 
181             "onselect", 
182             "onsubmit", 
183             "onunload", 
184             "outerHeight", 
185             "outerWidth", 
186             "pageXOffset", 
187             "pageYOffset", 
188             "personalbar", 
189             "plugins",
190             "prototype",
191             "screen", 
192             "screenLeft", 
193             "screenTop", 
194             "screenX", 
195             "screenY", 
196             "scrollX", 
197             "scrollY", 
198             "scrollbars", 
199             "status", 
200             "statusbar", 
201             "toolbar",
202             "history",
203         ];
204
205         var windowAttributesPropertiesAllowed = [
206             "closed",
207             "frames",
208             "length",
209             "opener",
210             "parent",
211             "self",
212             "top",
213             "window"
214         ];
215
216         window.onload = function()
217         {
218             if (window.testRunner) {
219                 testRunner.dumpAsText();
220                 testRunner.waitUntilDone();
221             }
222
223             if (window.testRunner) {
224                 setTimeout(pollForTest, 1);
225             } else {
226                 log("To run the test, click the button below when the opened window finishes loading.");
227                 var button = document.createElement("button");
228                 button.appendChild(document.createTextNode("Run Test"));
229                 button.onclick = runTest;
230                 document.body.appendChild(button);
231             }
232         }
233
234         pollForTest = function()
235         {
236             if (!testRunner.globalFlag) {
237                 setTimeout(pollForTest, 1);
238                 return;
239             }
240             runTest();
241             testRunner.notifyDone();
242         }
243
244         runTest = function()
245         {
246             window.targetWindow = frames[0];
247
248             log("\n----- tests for getting of not allowed properties -----\n");
249
250             log("\n----- tests for getting of not allowed Constructors -----\n");
251             for (var i = 0; i < windowConstructorPropertiesNotAllowed.length; i++) {
252                 var property = windowConstructorPropertiesNotAllowed[i];
253                 shouldBeFalse("canGetDescriptor(targetWindow, '" + property + "')");
254             }
255
256             log("\n----- tests for getting of not allowed Functions -----\n");
257             for (var i = 0; i < windowFunctionPropertiesNotAllowed.length; i++) {
258                 var property = windowFunctionPropertiesNotAllowed[i];
259                 shouldBeFalse("canGetDescriptor(targetWindow, '" + property + "')");
260             }
261
262             log("\n----- tests for getting of not allowed Attributes -----\n");
263             for (var i = 0; i < windowAttributesPropertiesNotAllowed.length; i++) {
264                 var property = windowAttributesPropertiesNotAllowed[i];
265                 if (property == "document")
266                     log("Firefox allows access to 'document' but throws an exception when you access its properties.");
267                 shouldBeFalse("canGetDescriptor(targetWindow, '" + property + "')");
268             }
269             for (var i = 0; i < windowAttributesPropertiesAllowed.length; i++) {
270                 var property = windowAttributesPropertiesAllowed[i];
271                 shouldBeTrue("canGetDescriptor(targetWindow, '" + property + "')");
272             }
273             log("----- tests access to cross domain location object -----");
274             window.targetLocation = targetWindow.location;
275             var locationProperties = [
276                 "protocol", "host", "hostname", "port", "pathname", "search", "hash", "toString", "valueOf", "customProperty", "reload"
277             ];
278             for (var i = 0; i < locationProperties.length; i++)
279                 shouldBeFalse("canGetDescriptor(targetLocation, '" + locationProperties[i] + "')");
280             var locationPropertiesAllowed = [
281                 "assign", "replace"
282             ];
283             for (var i = 0; i < locationPropertiesAllowed.length; i++)
284                 shouldBeTrue("canGetDescriptor(targetLocation, '" + locationPropertiesAllowed[i] + "')");
285
286             log("----- tests access to cross domain history object -----");
287             shouldThrowException("targetWindow.history");
288         }
289     </script>
290 </head>
291 <body>
292 <p>This test checks cross-frame access security of getOwnPropertyDescriptor (https://bugs.webkit.org/show_bug.cgi?id=32119).</p>
293 <iframe src="http://localhost:8000/security/resources/cross-frame-iframe-for-get-test.html" style=""></iframe>
294 <pre id="console"></pre>
295 </body>
296 </html>