| 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> | |
| 8 <script> | 7 <script> |
| 9 description("Cross-origin access through 'get' and 'set' in a property descripto
r should throw a SecurityError."); | 8 description("Cross-origin access to 'window.location.pathname' over 'get' and 's
et' in property descriptor should throw a SecurityError."); |
| 10 | 9 |
| 11 window.jsTestIsAsync = true; | 10 window.jsTestIsAsync = true; |
| 11 window.testRunner.setCanOpenWindows(true); |
| 12 | 12 |
| 13 var targetFrame = window['cross-origin-frame']; | 13 var targetWindow = window.open("http://localhost:8080/"); |
| 14 shouldBeNonNull(targetFrame); | |
| 15 var targetWindow = targetFrame.contentWindow; | |
| 16 shouldBeNonNull(targetWindow); | |
| 17 | 14 |
| 18 var pathnameDescriptor = Object.getOwnPropertyDescriptor(location, "pathname"); | 15 var pathnameDescriptor = Object.getOwnPropertyDescriptor(Location.prototype, "pa
thname"); |
| 19 shouldBeNonNull("pathnameDescriptor"); | 16 shouldBeNonNull("pathnameDescriptor"); |
| 20 shouldBe("typeof pathnameDescriptor.get", '"function"'); | 17 shouldBe("typeof pathnameDescriptor.get", '"function"'); |
| 21 shouldBe("typeof pathnameDescriptor.set", '"function"'); | 18 shouldBe("typeof pathnameDescriptor.set", '"function"'); |
| 22 | 19 |
| 23 var devicePixelRatioDescriptor = Object.getOwnPropertyDescriptor(window, "device
PixelRatio"); | 20 var count = 0; |
| 24 shouldBeNonNull("devicePixelRatio"); | 21 var timerId = window.setInterval(function() { |
| 25 shouldBe("typeof devicePixelRatioDescriptor.get", '"function"'); | 22 if (++count > 10) { |
| 26 shouldBe("typeof devicePixelRatioDescriptor.set", '"function"'); | 23 window.clearInterval(timerId); |
| 27 | 24 finishJSTest(); |
| 28 targetFrame.onload = function() { | 25 return; |
| 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."'); | 26 } |
| 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."'); | 27 if (targetWindow) { |
| 31 | 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."'); |
| 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."'); | 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."'); |
| 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."'); | 30 window.clearInterval(timerId); |
| 34 | 31 finishJSTest(); |
| 35 finishJSTest(); | 32 } |
| 36 }; | 33 }, 1000); |
| 37 </script> | 34 </script> |
| 38 </body> | 35 </body> |
| 39 </html> | 36 </html> |
| OLD | NEW |