OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../js/resources/js-test-pre.js"></script> |
| 5 </head> |
| 6 <body> |
| 7 <script> |
| 8 window.jsTestIsAsync = true; |
| 9 description("Tests that properties of various events do not leak between isolate
d worlds (bug 85158)."); |
| 10 |
| 11 function addListener(eventType, prop) { |
| 12 document.addEventListener(eventType, function(event) { |
| 13 documentObject = event[prop]; |
| 14 |
| 15 // Object passed into isolated world should be undefined. |
| 16 shouldBeNull("documentObject"); |
| 17 |
| 18 // The property defined in the isolated world should be undefined. |
| 19 shouldBeUndefined("document.pageDefinedVar"); |
| 20 |
| 21 window.postMessage("done", "*"); |
| 22 }); |
| 23 } |
| 24 |
| 25 function sendDocumentObject(eventType, prop) { |
| 26 var newEvent = eval("new " + eventType + "('" + eventType + "', { " + prop +
": document })"); |
| 27 document.dispatchEvent(newEvent); |
| 28 } |
| 29 |
| 30 function runScript(eventType, prop) { |
| 31 // Final string should have the form: |
| 32 // document.pageDefinedVar = 1; (function sendDocumentObject(eventType,
prop) {...})(...); |
| 33 // When evaluated in the isolated world, should initiate the event with the |
| 34 // document object as the specificed property value. |
| 35 var script = "document.pageDefinedVar = 1; " + |
| 36 "(" + sendDocumentObject.toString() + ")('" + eventType + "', '
" + prop + "');"; |
| 37 addListener(eventType, prop); |
| 38 testRunner.evaluateScriptInIsolatedWorld(1, script); |
| 39 } |
| 40 |
| 41 // Run the tests whenever a notification arrives, which indicates that the |
| 42 // previous test has finished. |
| 43 window.addEventListener("message", function(message) { |
| 44 runNextTest(); |
| 45 }, false); |
| 46 |
| 47 // The events that we want to test, with the properties that each one uses. |
| 48 var events = [ |
| 49 { eventType: "CustomEvent", prop: "detail" }, |
| 50 { eventType: "MessageEvent", prop: "data" }, |
| 51 { eventType: "PopStateEvent", prop: "state" } |
| 52 ]; |
| 53 |
| 54 function runNextTest () { |
| 55 var evt = events.pop(); |
| 56 if (!evt) { |
| 57 finishJSTest(); |
| 58 return; |
| 59 } |
| 60 |
| 61 runScript(evt.eventType, evt.prop); |
| 62 }; |
| 63 |
| 64 // This test is meaningless without testRunner. |
| 65 if (window.testRunner) { |
| 66 runNextTest(); |
| 67 } |
| 68 </script> |
| 69 </body> |
| 70 <script src="../js/resources/js-test-post.js"></script> |
| 71 </html> |
OLD | NEW |