3 <script src=
"resources/cross-frame-access.js"></script>
5 var windowConstructorPropertiesNotAllowed
= [
10 "CSSStyleDeclaration",
32 "HTMLDirectoryElement",
36 "HTMLFieldSetElement",
40 "HTMLFrameSetElement",
60 "HTMLOptGroupElement",
62 "HTMLParagraphElement",
70 "HTMLTableCaptionElement",
71 "HTMLTableCellElement",
72 "HTMLTableColElement",
74 "HTMLTableRowElement",
75 "HTMLTableSectionElement",
76 "HTMLTextAreaElement",
85 "ProcessingInstruction",
101 var windowFunctionPropertiesNotAllowed
= [
112 "getMatchedCSSRules",
120 "removeEventListener",
134 var windowAttributesPropertiesNotAllowed
= [
153 "offscreenBuffering",
200 var windowAttributesPropertiesAllowed
= [
211 window
.onload = function()
213 if (window
.testRunner
) {
214 testRunner
.dumpAsText();
215 testRunner
.waitUntilDone();
218 window
.addEventListener('message', function()
221 if (window
.testRunner
)
222 testRunner
.notifyDone();
228 window
.targetWindow
= frames
[0];
230 log("\n----- tests for getting of not allowed properties -----\n");
232 log("\n----- tests for getting of not allowed Constructors -----\n");
233 for (var i
= 0; i
< windowConstructorPropertiesNotAllowed
.length
; i
++) {
234 var property
= windowConstructorPropertiesNotAllowed
[i
];
235 shouldBeFalse("canGetDescriptor(targetWindow, '" + property
+ "')");
238 log("\n----- tests for getting of not allowed Functions -----\n");
239 for (var i
= 0; i
< windowFunctionPropertiesNotAllowed
.length
; i
++) {
240 var property
= windowFunctionPropertiesNotAllowed
[i
];
241 shouldBeFalse("canGetDescriptor(targetWindow, '" + property
+ "')");
244 log("\n----- tests for getting of not allowed Attributes -----\n");
245 for (var i
= 0; i
< windowAttributesPropertiesNotAllowed
.length
; i
++) {
246 var property
= windowAttributesPropertiesNotAllowed
[i
];
247 if (property
== "document")
248 log("Firefox allows access to 'document' but throws an exception when you access its properties.");
249 shouldBeFalse("canGetDescriptor(targetWindow, '" + property
+ "')");
251 for (var i
= 0; i
< windowAttributesPropertiesAllowed
.length
; i
++) {
252 var property
= windowAttributesPropertiesAllowed
[i
];
253 shouldBeTrue("canGetDescriptor(targetWindow, '" + property
+ "')");
255 log("----- tests access to cross domain location object -----");
256 window
.targetLocation
= targetWindow
.location
;
257 var locationProperties
= [
258 "protocol", "host", "hostname", "port", "pathname", "search", "hash", "toString", "valueOf", "customProperty", "reload"
260 for (var i
= 0; i
< locationProperties
.length
; i
++)
261 shouldBeFalse("canGetDescriptor(targetLocation, '" + locationProperties
[i
] + "')");
262 var locationPropertiesAllowed
= [
265 for (var i
= 0; i
< locationPropertiesAllowed
.length
; i
++)
266 shouldBeTrue("canGetDescriptor(targetLocation, '" + locationPropertiesAllowed
[i
] + "')");
268 log("----- tests access to cross domain history object -----");
269 shouldThrowException("targetWindow.history");
274 <p>This test checks cross-frame access security of getOwnPropertyDescriptor (https://bugs.webkit.org/show_bug.cgi?id=
32119).
</p>
275 <iframe src=
"http://localhost:8000/security/resources/cross-frame-iframe-for-get-test.html" style=
""></iframe>
276 <pre id=
"console"></pre>