OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="/js-test-resources/js-test.js"></script> | 4 <script src="/js-test-resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
| 7 <iframe id="cross-origin-frame" src="http://localhost:8000/resources/dummy.html"
></iframe> |
7 <script> | 8 <script> |
8 description("Cross-origin access to 'window.location.pathname' over 'get' and 's
et' in property descriptor should throw a SecurityError."); | 9 description("Cross-origin access through 'get' and 'set' in a property descripto
r should throw a SecurityError."); |
9 | 10 |
10 window.jsTestIsAsync = true; | 11 window.jsTestIsAsync = true; |
11 window.testRunner.setCanOpenWindows(true); | |
12 | 12 |
13 var targetWindow = window.open("http://localhost:8080/"); | 13 var targetFrame = window['cross-origin-frame']; |
| 14 shouldBeNonNull(targetFrame); |
| 15 var targetWindow = targetFrame.contentWindow; |
| 16 shouldBeNonNull(targetWindow); |
14 | 17 |
15 var pathnameDescriptor = Object.getOwnPropertyDescriptor(Location.prototype, "pa
thname"); | 18 var pathnameDescriptor = Object.getOwnPropertyDescriptor(location, "pathname"); |
16 shouldBeNonNull("pathnameDescriptor"); | 19 shouldBeNonNull("pathnameDescriptor"); |
17 shouldBe("typeof pathnameDescriptor.get", '"function"'); | 20 shouldBe("typeof pathnameDescriptor.get", '"function"'); |
18 shouldBe("typeof pathnameDescriptor.set", '"function"'); | 21 shouldBe("typeof pathnameDescriptor.set", '"function"'); |
19 | 22 |
20 var count = 0; | 23 var devicePixelRatioDescriptor = Object.getOwnPropertyDescriptor(window, "device
PixelRatio"); |
21 var timerId = window.setInterval(function() { | 24 shouldBeNonNull("devicePixelRatio"); |
22 if (++count > 10) { | 25 shouldBe("typeof devicePixelRatioDescriptor.get", '"function"'); |
23 window.clearInterval(timerId); | 26 shouldBe("typeof devicePixelRatioDescriptor.set", '"function"'); |
24 finishJSTest(); | 27 |
25 return; | 28 targetFrame.onload = function() { |
26 } | 29 shouldThrow("pathnameDescriptor.get.call(targetWindow.location)", '"SecurityEr
ror: Blocked a frame with origin \\"http://127.0.0.1:8000\\" from accessing a cr
oss-origin frame."'); |
27 if (targetWindow) { | 30 shouldThrow("pathnameDescriptor.set.call(targetWindow.location, 1)", '"Securit
yError: Blocked a frame with origin \\"http://127.0.0.1:8000\\" from accessing a
cross-origin frame."'); |
28 shouldThrow("pathnameDescriptor.get.call(targetWindow.location)", '"Secu
rityError: Blocked a frame with origin \\"http://127.0.0.1:8000\\" from accessin
g a cross-origin frame."'); | 31 |
29 shouldThrow("pathnameDescriptor.set.call(targetWindow.location, 1)", '"S
ecurityError: Blocked a frame with origin \\"http://127.0.0.1:8000\\" from acces
sing a cross-origin frame."'); | 32 shouldThrow("devicePixelRatioDescriptor.get.call(targetWindow)", '"SecurityErr
or: Blocked a frame with origin \\"http://127.0.0.1:8000\\" from accessing a cro
ss-origin frame."'); |
30 window.clearInterval(timerId); | 33 shouldThrow("devicePixelRatioDescriptor.set.call(targetWindow, 1)", '"Security
Error: Blocked a frame with origin \\"http://127.0.0.1:8000\\" from accessing a
cross-origin frame."'); |
31 finishJSTest(); | 34 |
32 } | 35 finishJSTest(); |
33 }, 1000); | 36 }; |
34 </script> | 37 </script> |
35 </body> | 38 </body> |
36 </html> | 39 </html> |
OLD | NEW |