gecko-dev/layout/generic/test/test_image_selection.html

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

105 lines
2.7 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=599368
-->
<head>
<title>Test for Bug 599368</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.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=599368">Mozilla Bug 599368</a>
<iframe id="display" src="about:blank"></iframe>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 599368 **/
SimpleTest.waitForExplicitFinish();
window.addEventListener("load", step1);
var gImage;
var gIframe;
var gBlueNotSelected;
var gBlueSelected;
var gFuchsiaSelected;
function step1()
{
gIframe = document.getElementById("display");
doc = gIframe.contentDocument;
gImage = doc.createElement('img');
var src = String(window.location).split("/");
src.pop();
src.push("blue-32x32.png");
src = src.join("/");
gImage.src = src;
gImage.addEventListener("load", step2);
doc.body.appendChild(gImage);
doc.designMode = "on";
}
function step2() {
gImage.removeEventListener("load", step2);
gBlueNotSelected = snapshotWindow(gIframe.contentWindow, false);
synthesizeMouse(gImage, 5, 5, {}, gIframe.contentWindow);
setTimeout(step3, 0);
}
function step3() {
gBlueSelected = snapshotWindow(gIframe.contentWindow, false);
var src = String(window.location).split("/");
src.pop();
src.push("fuchsia-32x32.png");
src = src.join("/");
gImage.addEventListener("load", step4);
gImage.src = src;
}
function step4() {
gImage.removeEventListener("load", step4);
gFuchsiaSelected = snapshotWindow(gIframe.contentWindow, false);
Bug 1449564 - part 1: Disable object resizer and inline table editor in default r=m_kato Gecko supports resizers of <img> elements and <table>, <td>, <th> elements and has UI to remove existing table row or column in default. However, the other browsers don't have such UI and web apps need to disable this feature with calling both: document.execCommand("enableObjectResizing", false, false); document.execCommand("enableInlineTableEditing", false, false); for avoiding conflicting with their own features to edit such elements. Therefore, it doesn't make sense to keep enabling them in default only on Gecko. If web apps want to keep using these features, they should call: document.execCommand("enableObjectResizing", false, true); document.execCommand("enableInlineTableEditing", false, true); at initializing the editor. And also this patch fixes bugs of document.queryCommandState("enableObjectResizing") and document.queryCommandState("enableInlineTableEditing"). They always return false even after calling document.execCommand(..., false, true) since nsSetDocumentStateCommand::GetCommandStateParams() sets bool value as STATE_ATTRIBUTE. However, nsHTMLDocument::QueryCommandValue() which is the caller referring STATE_ATTRIBUTE doesn't treat it as bool value. And also those commands are related to state of document. Therefore, they should be return as bool value of STATE_ALL instead. Then, nsHTMLDocument::QueryCommandState() returns the state as expected. Note that those commands are supported only by Gecko. So, we don't need to worry about the compatibility. Finally, this patch rewrites 2 existing tests to check basic behavior of resizers and appearance of resizers. Note that this patch does not add new tests to test inline table editor since it's difficult to test the behavior with current API. Perhaps, we should add an API to nsIHTMLEditor to retrieve each anonymous elements in another bug since it requires to add wrapping API of SpecialPowers. MozReview-Commit-ID: 1FhYo5vcV60 --HG-- rename : editor/libeditor/tests/test_objectResizing.html => editor/libeditor/tests/test_resizers_appearance.html rename : editor/libeditor/tests/test_bug640321.html => editor/libeditor/tests/test_resizers_resizing_elements.html extra : rebase_source : a707de5a64ef1f8ce974cdf1be093d1b4f61c7bc
2018-04-02 08:26:46 +00:00
if (gIframe.contentDocument.queryCommandState("enableObjectResizing")) {
assert_different(gBlueNotSelected, gBlueSelected,
"selecting image should add drag points");
} else {
assert_equal(gBlueNotSelected, gBlueSelected,
"selecting image should not change anything visually");
}
assert_different(gBlueSelected, gFuchsiaSelected,
"different images should appear different");
SimpleTest.finish();
}
Bug 1449564 - part 1: Disable object resizer and inline table editor in default r=m_kato Gecko supports resizers of <img> elements and <table>, <td>, <th> elements and has UI to remove existing table row or column in default. However, the other browsers don't have such UI and web apps need to disable this feature with calling both: document.execCommand("enableObjectResizing", false, false); document.execCommand("enableInlineTableEditing", false, false); for avoiding conflicting with their own features to edit such elements. Therefore, it doesn't make sense to keep enabling them in default only on Gecko. If web apps want to keep using these features, they should call: document.execCommand("enableObjectResizing", false, true); document.execCommand("enableInlineTableEditing", false, true); at initializing the editor. And also this patch fixes bugs of document.queryCommandState("enableObjectResizing") and document.queryCommandState("enableInlineTableEditing"). They always return false even after calling document.execCommand(..., false, true) since nsSetDocumentStateCommand::GetCommandStateParams() sets bool value as STATE_ATTRIBUTE. However, nsHTMLDocument::QueryCommandValue() which is the caller referring STATE_ATTRIBUTE doesn't treat it as bool value. And also those commands are related to state of document. Therefore, they should be return as bool value of STATE_ALL instead. Then, nsHTMLDocument::QueryCommandState() returns the state as expected. Note that those commands are supported only by Gecko. So, we don't need to worry about the compatibility. Finally, this patch rewrites 2 existing tests to check basic behavior of resizers and appearance of resizers. Note that this patch does not add new tests to test inline table editor since it's difficult to test the behavior with current API. Perhaps, we should add an API to nsIHTMLEditor to retrieve each anonymous elements in another bug since it requires to add wrapping API of SpecialPowers. MozReview-Commit-ID: 1FhYo5vcV60 --HG-- rename : editor/libeditor/tests/test_objectResizing.html => editor/libeditor/tests/test_resizers_appearance.html rename : editor/libeditor/tests/test_bug640321.html => editor/libeditor/tests/test_resizers_resizing_elements.html extra : rebase_source : a707de5a64ef1f8ce974cdf1be093d1b4f61c7bc
2018-04-02 08:26:46 +00:00
function assert_equal(shot1, shot2, desc)
{
var [correct, s1, s2] = compareSnapshots(shot1, shot2, true);
ok(correct, desc + (correct ? "" : "\nRESULT: " + s2));
}
function assert_different(shot1, shot2, desc)
{
var [correct, s1, s2] = compareSnapshots(shot1, shot2, false);
ok(correct, desc);
}
</script>
</pre>
</body>
</html>