forked from mirrors/gecko-dev
Bug 1848966 - Remove dom.document.exec_command.nested_calls_allowed pref r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D212578
This commit is contained in:
parent
d421099c60
commit
82e064164d
11 changed files with 1 additions and 233 deletions
|
|
@ -5392,8 +5392,7 @@ bool Document::ExecCommand(const nsAString& aHTMLCommandName, bool aShowUI,
|
|||
|
||||
// If we're running an execCommand, we should just return false.
|
||||
// https://github.com/w3c/editing/issues/200#issuecomment-575241816
|
||||
if (!StaticPrefs::dom_document_exec_command_nested_calls_allowed() &&
|
||||
!markRunningExecCommand.IsSafeToRun()) {
|
||||
if (!markRunningExecCommand.IsSafeToRun()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
<script>
|
||||
function onLoad() {
|
||||
// For emulating the traditional behavior, collapse Selection to end of the
|
||||
// parent of <embed> (<embed> is not a container, therefore, its parent is the
|
||||
// deepest last child container element of the <body>).
|
||||
getSelection().collapse(
|
||||
document.querySelector("embed").parentElement,
|
||||
document.querySelector("embed").parentElement.childNodes.length
|
||||
); // Point the <embed>
|
||||
const option = document.querySelector("option");
|
||||
option.addEventListener("click", () => {
|
||||
document.execCommand("forwardDelete");
|
||||
});
|
||||
const li2 = document.getElementById("li2");
|
||||
li2.addEventListener("DOMNodeInserted", () => {
|
||||
option.click();
|
||||
});
|
||||
const select = document.querySelector("select");
|
||||
select.parentElement.setAttribute("onpageshow", "onPageShow()");
|
||||
}
|
||||
|
||||
function onPageShow() {
|
||||
const li1 = document.getElementById("li1");
|
||||
li1.addEventListener("DOMSubtreeModified", () => {
|
||||
document.execCommand("selectAll");
|
||||
document.execCommand("indent");
|
||||
});
|
||||
li1.appendChild(document.createElement("legend"));
|
||||
}
|
||||
</script>
|
||||
<body onload="onLoad()">
|
||||
<select>
|
||||
<option></option>
|
||||
</select>
|
||||
<li id="li1"></li>
|
||||
<ul contenteditable="true">
|
||||
<li id="li2"></li>
|
||||
<embed>a;#2
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
<script>
|
||||
let th;
|
||||
function onLoad() {
|
||||
// For emulating the traditional behavior, collapse Selection to end of the
|
||||
// <colgroup> which is the last child of the <body>.
|
||||
getSelection().collapse(
|
||||
document.querySelector("colgroup"),
|
||||
document.querySelector("colgroup").childNodes.length
|
||||
);
|
||||
th = document.querySelector("th"); // Cache the target for removing the event handler.
|
||||
try {
|
||||
th.addEventListener("DOMSubtreeModified", onDOMSubtreeModified);
|
||||
} catch(e) {}
|
||||
try {
|
||||
th.align = "";
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
let count = 0;
|
||||
function onDOMSubtreeModified() {
|
||||
if (count++ == 1) {
|
||||
// If we didn't stop testing this, this event handler would be called too
|
||||
// many times. It's enough to run twice to reproduce the bug report.
|
||||
th.removeEventListener("DOMSubtreeModified", onDOMSubtreeModified);
|
||||
}
|
||||
try {
|
||||
document.execCommand("selectAll");
|
||||
} catch(e) {}
|
||||
try {
|
||||
document.execCommand("justifyCenter");
|
||||
} catch(e) {}
|
||||
try {
|
||||
document.execCommand("forwardDelete");
|
||||
} catch(e) {}
|
||||
}
|
||||
</script>
|
||||
<body onload="onLoad()">
|
||||
<table contenteditable>
|
||||
<th></th>
|
||||
<colgroup></body>
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
<script>
|
||||
var count = 0;
|
||||
function onLoad() {
|
||||
// For emulating the traditional behavior, collapse Selection to end of the
|
||||
// text node in the <s> which is the deepest last child (and a container) of
|
||||
// the <body> (i.e., end of the the text node after the last comment node).
|
||||
const s = document.querySelector("s");
|
||||
getSelection().collapse(s.lastChild, s.lastChild.length);
|
||||
document.execCommand("delete");
|
||||
}
|
||||
|
||||
function onInputOrDOMNodeInserted() {
|
||||
if (++count >= 3) {
|
||||
return;
|
||||
}
|
||||
addEventListener("DOMNodeInserted", onInputOrDOMNodeInserted);
|
||||
document.execCommand("removeFormat");
|
||||
document.execCommand("insertText", false, "1");
|
||||
}
|
||||
</script>
|
||||
<body onload="onLoad()">
|
||||
<ol oninput="onInputOrDOMNodeInserted()" contenteditable>
|
||||
<!-- x -->
|
||||
<s>
|
||||
<!-- x -->
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
<script>
|
||||
function onLoad() {
|
||||
const dd = document.querySelector("dd[contenteditable]");
|
||||
// For emulating the traditional behavior, collapse Selection to end of the
|
||||
// text node at end of the <dd contenteditable> which is the deepest last
|
||||
// child of the <body> (end of the text node after the <template>).
|
||||
getSelection().collapse(dd.lastChild, dd.lastChild.length);
|
||||
getSelection().setPosition(
|
||||
document.querySelector("template")
|
||||
);
|
||||
dd.addEventListener("DOMNodeInserted", () => {
|
||||
document.execCommand("selectAll");
|
||||
document.execCommand("insertText", false, "");
|
||||
});
|
||||
document.execCommand("insertImage", false, "#");
|
||||
}
|
||||
</script>
|
||||
<body onload="onLoad()">
|
||||
<dd contenteditable>
|
||||
<template></template>
|
||||
</dd></body>
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<script>
|
||||
function onError() {
|
||||
document.querySelector("details").appendChild(
|
||||
document.querySelector("p")
|
||||
);
|
||||
document.execCommand("indent");
|
||||
}
|
||||
|
||||
function onLoadOfStyle() {
|
||||
document.execCommand("delete");
|
||||
document.querySelector("details").contentEditable = "true";
|
||||
// For emulating the traditional behavior, collapse Selection to end of the
|
||||
// text node at end of the <style> (end of the text node after the comment
|
||||
// node).
|
||||
const style = document.querySelector("style");
|
||||
getSelection().collapse(style.lastChild, style.lastChild.length);
|
||||
document.querySelector("input").select();
|
||||
}
|
||||
</script>
|
||||
<video focus="false">
|
||||
<source onerror="onError()">
|
||||
</video>
|
||||
<details open>
|
||||
<p>
|
||||
<input contenteditable="false">
|
||||
<style onload="onLoadOfStyle()">
|
||||
<!-- x -->
|
||||
</style></p></details></body>
|
||||
|
|
@ -58,8 +58,6 @@ load 1393171.html
|
|||
needs-focus load 1402196.html
|
||||
load 1402469.html
|
||||
load 1402526.html
|
||||
pref(dom.document.exec_command.nested_calls_allowed,true) asserts(1) load 1402904.html # assertion is that mutation event listener caused by execCommand calls another execCommand
|
||||
pref(dom.document.exec_command.nested_calls_allowed,true) asserts(1) load 1405747.html # assertion is that mutation event listener caused by execCommand calls another execCommand
|
||||
load 1405897.html
|
||||
load 1408170.html
|
||||
asserts(0-1) load 1414581.html
|
||||
|
|
@ -75,9 +73,7 @@ load 1441619.html
|
|||
load 1443664.html
|
||||
skip-if(Android) needs-focus load 1444630.html
|
||||
load 1446451.html
|
||||
pref(dom.document.exec_command.nested_calls_allowed,true) load 1464251.html
|
||||
pref(layout.accessiblecaret.enabled,true) load 1470926.html
|
||||
pref(dom.document.exec_command.nested_calls_allowed,true) asserts(2) load 1474978.html # assertion is that mutation event listener caused by execCommand calls another execCommand
|
||||
load 1517028.html
|
||||
load 1525481.html
|
||||
load 1533913.html
|
||||
|
|
@ -109,7 +105,6 @@ load 1659717.html
|
|||
load 1663725.html # throws
|
||||
load 1655508.html
|
||||
load 1655988.html
|
||||
pref(dom.document.exec_command.nested_calls_allowed,true) load 1666556.html
|
||||
load 1677566.html
|
||||
load 1691051.html
|
||||
load 1699866.html
|
||||
|
|
|
|||
|
|
@ -381,8 +381,6 @@ skip-if = ["headless"]
|
|||
|
||||
["test_bug1409520.html"]
|
||||
|
||||
["test_bug1425997.html"]
|
||||
|
||||
["test_bug1543312.html"]
|
||||
|
||||
["test_bug1568996.html"]
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1425997
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for Bug 1425997</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1425997">Mozilla Bug 1425997</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none;">
|
||||
|
||||
</div>
|
||||
|
||||
<div id="editor" contenteditable>
|
||||
<!-- -->
|
||||
<span id="inline">foo</span>
|
||||
</div>
|
||||
|
||||
<pre id="test">
|
||||
|
||||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
// 2 assertions are recorded due to nested execCommand() but not a problem.
|
||||
// They are necessary to detect invalid method call without mutation event listers.
|
||||
SimpleTest.expectAssertions(2, 2);
|
||||
SimpleTest.waitForFocus(async function() {
|
||||
await SpecialPowers.pushPrefEnv({set: [["dom.document.exec_command.nested_calls_allowed", true]]});
|
||||
let selection = window.getSelection();
|
||||
let editor = document.getElementById("editor");
|
||||
function onCharacterDataModified() {
|
||||
// Until removing all NBSPs which were inserted by the editor,
|
||||
// emulates Backspace key with "delete" command.
|
||||
// When this test is created, the behavior was:
|
||||
// after 1st delete: "\n<!-- --> \n"
|
||||
// after 2nd delete: "\n<!-- --> "
|
||||
// Then, selection is moved into the comment node and deletion won't
|
||||
// work after that.
|
||||
while (editor.innerHTML.includes(" ")) {
|
||||
let preInnerHTML = editor.innerHTML;
|
||||
if (!document.execCommand("delete", false) || preInnerHTML === editor.innerHTML) {
|
||||
break;
|
||||
}
|
||||
info(`editor.innerHTML: "${editor.innerHTML.replace(/\n/g, "\\n")}"`);
|
||||
}
|
||||
}
|
||||
editor.addEventListener("DOMCharacterDataModified", onCharacterDataModified, { once: true });
|
||||
editor.focus();
|
||||
selection.selectAllChildren(document.getElementById("inline"));
|
||||
document.execCommand("insertHTML", false, "text");
|
||||
// This expected result is just same as the result of Chrome.
|
||||
// If the spec says this is wrong, feel free to change this result.
|
||||
todo_is(editor.innerHTML, "\n<!-- --><span id=\"inline\">text</span>",
|
||||
"The 'foo' should be replaced with 'text' and whitespaces before the span element should be removed");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -2378,13 +2378,6 @@
|
|||
value: @IS_NOT_EARLY_BETA_OR_EARLIER@
|
||||
mirror: always
|
||||
|
||||
# If set this to true, `Document.execCommand` may be performed nestedly.
|
||||
# Otherwise, nested calls just return false.
|
||||
- name: dom.document.exec_command.nested_calls_allowed
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# Only intended for fuzzing purposes, this will break mozPrintCallback, etc.
|
||||
- name: dom.window_print.fuzzing.block_while_printing
|
||||
type: bool
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
[backcolor-in-nested-editing-host-td-from-DOMAttrModified.html]
|
||||
prefs: [dom.document.exec_command.nested_calls_allowed:true]
|
||||
Loading…
Reference in a new issue