| <!DOCTYPE html> |
| <html> |
| <body> |
| <script src="../../resources/js-test.js"></script> |
| <script> |
| description("Tests that event handlers are not called in detached documents, even if the event is dispatched by JavaScript. This test passes if you do not see a FAIL alert message."); |
| jsTestIsAsync = true; |
| |
| let doc = new DOMParser().parseFromString('<video src=x onerror=alert("FAIL1")>','text/html'); |
| let video = doc.body.firstChild; |
| shouldBe("video.__proto__", "HTMLVideoElement.prototype"); |
| video.dispatchEvent(new CustomEvent("error")); |
| |
| doc = new DOMParser().parseFromString('<video onerror=alert(event.expected)>','text/html'); |
| video = doc.body.firstChild; |
| shouldBe("video.__proto__", "HTMLVideoElement.prototype"); |
| let failEvent = new CustomEvent("error"); |
| failEvent.expected = "FAIL"; |
| video.dispatchEvent(failEvent); |
| debug("Adopting node into a document that has a frame"); |
| document.adoptNode(video); |
| let passEvent = new CustomEvent("error"); |
| passEvent.expected = "PASS"; |
| video.dispatchEvent(passEvent); |
| |
| |
| setTimeout(finishJSTest, 0); |
| </script> |
| </body> |
| </html> |