blob: 24d29573d29963387ab1eb1378d5edb416933709 [file] [log] [blame]
<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
// These tests are specially written as async because webkitBeforeTextInserted
// event was unable to fire the event listener on an iframe without 'src'.
const tests = [];
function runTestIfAny() {
const next = tests.shift();
if (next)
next.testStep(next.testObject);
}
tests.push({
testObject: async_test('Should not crash when webkitBeforeTextInserted handler removes current frame in InsertText'),
testStep: t => {
const iframe = document.createElement('iframe');
iframe.src = '../resources/contenteditable-iframe-src.html';
iframe.onload = t.step_func_done(() => {
iframe.contentDocument.body.addEventListener('webkitBeforeTextInserted', () => {
iframe.remove();
t.done();
});
iframe.contentDocument.body.focus();
iframe.contentDocument.execCommand('insertText', false, 'x');
});
document.body.appendChild(iframe);
}});
tests.push({
testObject: async_test('Should not crash when webkitBeforeTextInserted handler removes current frame in InsertLineBreak'),
testStep: t => {
const iframe = document.createElement('iframe');
iframe.src = '../resources/contenteditable-iframe-src.html';
iframe.onload = t.step_func_done(() => {
iframe.contentDocument.body.addEventListener('webkitBeforeTextInserted', () => {
iframe.remove();
t.done();
});
iframe.contentDocument.body.focus();
iframe.contentDocument.execCommand('insertLineBreak');
});
document.body.appendChild(iframe);
}});
tests.push({
testObject: async_test('Should not crash when webkitBeforeTextInserted handler removes current frame in InsertParagraph'),
testStep: t => {
const iframe = document.createElement('iframe');
iframe.src = '../resources/contenteditable-iframe-src.html';
iframe.onload = t.step_func(() => {
iframe.contentDocument.body.addEventListener('webkitBeforeTextInserted', () => {
iframe.remove();
t.done();
});
iframe.contentDocument.body.focus();
iframe.contentDocument.execCommand('insertParagraph');
});
document.body.appendChild(iframe);
}});
add_result_callback(runTestIfAny);
window.onload = runTestIfAny;
</script>