Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML: document.open() and event listener removal #12122

Merged
merged 2 commits into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe src="004-1.html"></iframe>
<iframe src="/common/blank.html"></iframe>
<script>
var t = async_test();
var iframe;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe src="004-1.html"></iframe>
<iframe src="/common/blank.html"></iframe>
<script>
var t = async_test();
var iframe;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe src="004-1.html"></iframe>
<iframe src="/common/blank.html"></iframe>
<script>
var t = async_test();
var iframe;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe src="004-1.html"></iframe>
<iframe src="/common/blank.html"></iframe>
<script>
var t = async_test();
var iframe;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe src="004-1.html"></iframe>
<iframe src="/common/blank.html"></iframe>
<script>
var iframe = document.getElementsByTagName("iframe")[0];
var steps;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
test(t => {
const frame = document.body.appendChild(document.createElement("iframe")),
body = frame.contentDocument.body;
t.add_cleanup(() => frame.remove());
const div = body.appendChild(frame.contentDocument.createElement("div"));
div.addEventListener("click", t.unreached_func("element event listener not removed"));
frame.contentDocument.open();
div.click();
frame.contentDocument.close();
}, "Standard event listeners are to be removed");

test(t => {
const frame = document.body.appendChild(document.createElement("iframe")),
body = frame.contentDocument.body;
Expand All @@ -8,7 +19,64 @@ test(t => {
frame.contentDocument.dispatchEvent(new Event("x"));
body.dispatchEvent(new Event("x"));
frame.contentDocument.close();
}, "Event listeners are to be removed");
}, "Custom event listeners are to be removed");

test(t => {
const frame = document.body.appendChild(document.createElement("iframe")),
body = frame.contentDocument.body;
t.add_cleanup(() => frame.remove());
// Focus on the current window so that the frame's window is blurred.
window.focus();
assert_false(frame.contentDocument.hasFocus());
frame.contentWindow.addEventListener("focus", t.unreached_func("window event listener not removed"));
body.onfocus = t.unreached_func("body event listener not removed");
frame.contentDocument.open();
assert_equals(body.onfocus, null);
frame.contentWindow.focus();
frame.contentDocument.close();
}, "Standard event listeners are to be removed from Window");

test(t => {
const frame = document.body.appendChild(document.createElement("iframe"));
t.add_cleanup(() => frame.remove());
frame.contentWindow.addEventListener("x", t.unreached_func("window event listener not removed"));
frame.contentDocument.open();
frame.contentWindow.dispatchEvent(new Event("x"));
frame.contentDocument.close();
}, "Custom event listeners are to be removed from Window");

test(t => {
const frame = document.body.appendChild(document.createElement("iframe")),
body = frame.contentDocument.body;
t.add_cleanup(() => frame.remove());
const div = body.appendChild(frame.contentDocument.createElement("div"));
div.onclick = t.unreached_func("element event listener not removed");
frame.contentDocument.open();
assert_equals(div.onclick, null);
const e = frame.contentDocument.createEvent("mouseevents")
e.initEvent("click", false, false);
div.dispatchEvent(e);
frame.contentDocument.close();
}, "IDL attribute event handlers are to be deactivated");

var thrower;

test(t => {
const frame = document.body.appendChild(document.createElement("iframe")),
body = frame.contentDocument.body;
t.add_cleanup(() => frame.remove());
const div = body.appendChild(frame.contentDocument.createElement("div"));
thrower = t.step_func(() => { throw new Error('element event listener not removed'); });
div.setAttribute("onclick", "parent.thrower()");
assert_not_equals(div.onclick, null);
frame.contentDocument.open();
assert_equals(div.getAttribute("onclick"), "parent.thrower()");
assert_equals(div.onclick, null);
const e = frame.contentDocument.createEvent("mouseevents")
e.initEvent("click", false, false);
div.dispatchEvent(e);
frame.contentDocument.close();
}, "Content attribute event handlers are to be deactivated");

test(t => {
const frame = document.body.appendChild(document.createElement("iframe"));
Expand Down