mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Backed out 3 changesets (bug 1692673) for bc failures in browser_contextmenu_input.js. CLOSED TREE
Backed out changeset 6060fa16bc3e (bug 1692673) Backed out changeset 0f6717c26ae3 (bug 1692673) Backed out changeset 8148b9e5dfba (bug 1692673)
This commit is contained in:
parent
fe80f6dc33
commit
b073741c99
@ -1203,9 +1203,6 @@ add_task(async function test_copylinkcommand() {
|
|||||||
"http://mozilla.com/",
|
"http://mozilla.com/",
|
||||||
"paste for command cmd_paste"
|
"paste for command cmd_paste"
|
||||||
);
|
);
|
||||||
// Don't keep focus, because that may affect clipboard commands in
|
|
||||||
// subsequently-opened menus.
|
|
||||||
input.blur();
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
function checkCommandState(testid, undoEnabled, copyEnabled, deleteEnabled) {
|
function checkCommandState(testid, undoEnabled, deleteEnabled) {
|
||||||
is(
|
is(
|
||||||
!document.getElementById("cmd_undo").hasAttribute("disabled"),
|
!document.getElementById("cmd_undo").hasAttribute("disabled"),
|
||||||
undoEnabled,
|
undoEnabled,
|
||||||
@ -6,9 +6,9 @@ function checkCommandState(testid, undoEnabled, copyEnabled, deleteEnabled) {
|
|||||||
);
|
);
|
||||||
is(
|
is(
|
||||||
!document.getElementById("cmd_copy").hasAttribute("disabled"),
|
!document.getElementById("cmd_copy").hasAttribute("disabled"),
|
||||||
copyEnabled,
|
true,
|
||||||
testid + " copy"
|
testid + " copy"
|
||||||
);
|
); // copy should always be enabled
|
||||||
is(
|
is(
|
||||||
!document.getElementById("cmd_delete").hasAttribute("disabled"),
|
!document.getElementById("cmd_delete").hasAttribute("disabled"),
|
||||||
deleteEnabled,
|
deleteEnabled,
|
||||||
@ -69,9 +69,7 @@ add_task(async function test_controllers_subframes() {
|
|||||||
"root focused"
|
"root focused"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
// XXX Currently, Copy is always enabled when the root (not an editor element)
|
checkCommandState("step " + stepNum + " root focused", false, false);
|
||||||
// is focused. Possibly that should only be true if a listener is present?
|
|
||||||
checkCommandState("step " + stepNum + " root focused", false, true, false);
|
|
||||||
|
|
||||||
// Tab to the textbox.
|
// Tab to the textbox.
|
||||||
await keyAndUpdate("VK_TAB", {}, 1);
|
await keyAndUpdate("VK_TAB", {}, 1);
|
||||||
@ -87,16 +85,11 @@ add_task(async function test_controllers_subframes() {
|
|||||||
"input focused"
|
"input focused"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
checkCommandState(
|
checkCommandState("step " + stepNum + " input focused", false, false);
|
||||||
"step " + stepNum + " input focused",
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
// Type into the textbox.
|
// Type into the textbox.
|
||||||
await keyAndUpdate("a", {}, 1);
|
await keyAndUpdate("a", {}, 1);
|
||||||
checkCommandState("step " + stepNum + " typed", true, false, false);
|
checkCommandState("step " + stepNum + " typed", true, false);
|
||||||
|
|
||||||
await SpecialPowers.spawn(browsingContexts[stepNum], [], () => {
|
await SpecialPowers.spawn(browsingContexts[stepNum], [], () => {
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
@ -106,13 +99,13 @@ add_task(async function test_controllers_subframes() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Select all text; this causes the Copy and Delete commands to be enabled.
|
// Select all text.
|
||||||
await keyAndUpdate("a", { accelKey: true }, 1);
|
await keyAndUpdate("a", { accelKey: true }, 1);
|
||||||
if (AppConstants.platform != "macosx") {
|
if (AppConstants.platform != "macosx") {
|
||||||
goUpdateGlobalEditMenuItems(true);
|
goUpdateGlobalEditMenuItems(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkCommandState("step " + stepNum + " selected", true, true, true);
|
checkCommandState("step " + stepNum + " selected", true, true);
|
||||||
|
|
||||||
// Now make sure that the text is selected.
|
// Now make sure that the text is selected.
|
||||||
await SpecialPowers.spawn(browsingContexts[stepNum], [], () => {
|
await SpecialPowers.spawn(browsingContexts[stepNum], [], () => {
|
||||||
|
@ -1248,7 +1248,7 @@ NS_IMETHODIMP EditorBase::CanCut(bool* aCanCut) {
|
|||||||
if (NS_WARN_IF(!aCanCut)) {
|
if (NS_WARN_IF(!aCanCut)) {
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
*aCanCut = MOZ_KnownLive(AsTextEditor())->IsCutCommandEnabled();
|
*aCanCut = AsTextEditor()->IsCutCommandEnabled();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1258,7 +1258,7 @@ NS_IMETHODIMP EditorBase::CanCopy(bool* aCanCopy) {
|
|||||||
if (NS_WARN_IF(!aCanCopy)) {
|
if (NS_WARN_IF(!aCanCopy)) {
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
*aCanCopy = MOZ_KnownLive(AsTextEditor())->IsCopyCommandEnabled();
|
*aCanCopy = AsTextEditor()->IsCopyCommandEnabled();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,11 +13,9 @@
|
|||||||
#include "PlaceholderTransaction.h"
|
#include "PlaceholderTransaction.h"
|
||||||
#include "gfxFontUtils.h"
|
#include "gfxFontUtils.h"
|
||||||
#include "mozilla/Assertions.h"
|
#include "mozilla/Assertions.h"
|
||||||
#include "mozilla/ContentEvents.h"
|
|
||||||
#include "mozilla/ContentIterator.h"
|
#include "mozilla/ContentIterator.h"
|
||||||
#include "mozilla/EditAction.h"
|
#include "mozilla/EditAction.h"
|
||||||
#include "mozilla/EditorDOMPoint.h"
|
#include "mozilla/EditorDOMPoint.h"
|
||||||
#include "mozilla/EventDispatcher.h"
|
|
||||||
#include "mozilla/HTMLEditor.h"
|
#include "mozilla/HTMLEditor.h"
|
||||||
#include "mozilla/IMEStateManager.h"
|
#include "mozilla/IMEStateManager.h"
|
||||||
#include "mozilla/LookAndFeel.h"
|
#include "mozilla/LookAndFeel.h"
|
||||||
@ -56,7 +54,6 @@
|
|||||||
#include "nsIWeakReferenceUtils.h"
|
#include "nsIWeakReferenceUtils.h"
|
||||||
#include "nsNameSpaceManager.h"
|
#include "nsNameSpaceManager.h"
|
||||||
#include "nsLiteralString.h"
|
#include "nsLiteralString.h"
|
||||||
#include "nsPresContext.h"
|
|
||||||
#include "nsReadableUtils.h"
|
#include "nsReadableUtils.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
@ -1217,64 +1214,17 @@ bool TextEditor::AreClipboardCommandsUnconditionallyEnabled() const {
|
|||||||
return document && document->AreClipboardCommandsUnconditionallyEnabled();
|
return document && document->AreClipboardCommandsUnconditionallyEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextEditor::CheckForClipboardCommandListener(
|
|
||||||
nsAtom* aCommand, EventMessage aEventMessage) const {
|
|
||||||
RefPtr<Document> document = GetDocument();
|
|
||||||
if (!document) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We exclude XUL and chrome docs here to maintain current behavior where
|
|
||||||
// in these cases the editor element alone is expected to handle clipboard
|
|
||||||
// command availability.
|
|
||||||
if (!document->AreClipboardCommandsUnconditionallyEnabled()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// So in web content documents, "unconditionally" enabled Cut/Copy are not
|
|
||||||
// really unconditional; they're enabled if there is a listener that wants
|
|
||||||
// to handle them. What they're not conditional on here is whether there is
|
|
||||||
// currently a selection in the editor.
|
|
||||||
RefPtr<PresShell> presShell = document->GetObservingPresShell();
|
|
||||||
if (!presShell) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
RefPtr<nsPresContext> presContext = presShell->GetPresContext();
|
|
||||||
if (!presContext) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<EventTarget> et = GetDOMEventTarget();
|
|
||||||
while (et) {
|
|
||||||
EventListenerManager* elm = et->GetOrCreateListenerManager();
|
|
||||||
if (elm && elm->HasListenersFor(aCommand)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
InternalClipboardEvent event(true, aEventMessage);
|
|
||||||
EventChainPreVisitor visitor(presContext, &event, nullptr,
|
|
||||||
nsEventStatus_eIgnore, false, et);
|
|
||||||
et->GetEventTargetParent(visitor);
|
|
||||||
et = visitor.GetParentTarget();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TextEditor::IsCutCommandEnabled() const {
|
bool TextEditor::IsCutCommandEnabled() const {
|
||||||
AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);
|
AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);
|
||||||
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsModifiable() && IsCopyToClipboardAllowedInternal()) {
|
if (AreClipboardCommandsUnconditionallyEnabled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's an event listener for "cut", we always enable the command
|
return IsModifiable() && IsCopyToClipboardAllowedInternal();
|
||||||
// as we don't really know what the listener may want to do in response.
|
|
||||||
// We look up the event target chain for a possible listener on a parent
|
|
||||||
// in addition to checking the immediate target.
|
|
||||||
return CheckForClipboardCommandListener(nsGkAtoms::oncut, eCut);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP TextEditor::Copy() {
|
NS_IMETHODIMP TextEditor::Copy() {
|
||||||
@ -1296,12 +1246,11 @@ bool TextEditor::IsCopyCommandEnabled() const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsCopyToClipboardAllowedInternal()) {
|
if (AreClipboardCommandsUnconditionallyEnabled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Like "cut", always enable "copy" if there's a listener.
|
return IsCopyToClipboardAllowedInternal();
|
||||||
return CheckForClipboardCommandListener(nsGkAtoms::oncopy, eCopy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextEditor::CanDeleteSelection() const {
|
bool TextEditor::CanDeleteSelection() const {
|
||||||
|
@ -96,7 +96,7 @@ class TextEditor : public EditorBase, public nsITimerCallback, public nsINamed {
|
|||||||
* disabled. This always returns true if we're in non-chrome HTML/XHTML
|
* disabled. This always returns true if we're in non-chrome HTML/XHTML
|
||||||
* document. Otherwise, same as the result of `IsCopyToClipboardAllowed()`.
|
* document. Otherwise, same as the result of `IsCopyToClipboardAllowed()`.
|
||||||
*/
|
*/
|
||||||
MOZ_CAN_RUN_SCRIPT bool IsCutCommandEnabled() const;
|
bool IsCutCommandEnabled() const;
|
||||||
|
|
||||||
NS_IMETHOD Copy() override;
|
NS_IMETHOD Copy() override;
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ class TextEditor : public EditorBase, public nsITimerCallback, public nsINamed {
|
|||||||
* This always returns true if we're in non-chrome HTML/XHTML document.
|
* This always returns true if we're in non-chrome HTML/XHTML document.
|
||||||
* Otherwise, same as the result of `IsCopyToClipboardAllowed()`.
|
* Otherwise, same as the result of `IsCopyToClipboardAllowed()`.
|
||||||
*/
|
*/
|
||||||
MOZ_CAN_RUN_SCRIPT bool IsCopyCommandEnabled() const;
|
bool IsCopyCommandEnabled() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IsCopyToClipboardAllowed() returns true if the selected content can
|
* IsCopyToClipboardAllowed() returns true if the selected content can
|
||||||
@ -786,13 +786,6 @@ class TextEditor : public EditorBase, public nsITimerCallback, public nsINamed {
|
|||||||
bool aNotify,
|
bool aNotify,
|
||||||
bool aForceStartMasking);
|
bool aForceStartMasking);
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper for Is{Cut|Copy}CommandEnabled.
|
|
||||||
* Look for a listener for the given command, including up the target chain.
|
|
||||||
*/
|
|
||||||
MOZ_CAN_RUN_SCRIPT bool CheckForClipboardCommandListener(
|
|
||||||
nsAtom* aCommand, EventMessage aEventMessage) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
mutable nsCOMPtr<nsIDocumentEncoder> mCachedDocumentEncoder;
|
mutable nsCOMPtr<nsIDocumentEncoder> mCachedDocumentEncoder;
|
||||||
|
|
||||||
|
@ -24,182 +24,41 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1067255
|
|||||||
|
|
||||||
function doTest() {
|
function doTest() {
|
||||||
var text = $("text-field");
|
var text = $("text-field");
|
||||||
var textWithHandlers = $("text-field-2");
|
|
||||||
var password = $("password-field");
|
var password = $("password-field");
|
||||||
var passwordWithHandlers = $("password-field-2");
|
|
||||||
var textWithParentHandlers = $("text-field-3");
|
|
||||||
var passwordWithParentHandlers = $("password-field-3");
|
|
||||||
var textarea1 = $("text-area-1");
|
|
||||||
var textarea2 = $("text-area-2");
|
|
||||||
var textarea3 = $("text-area-3");
|
|
||||||
|
|
||||||
var editor1 = SpecialPowers.wrap(text).editor;
|
var editor1 = SpecialPowers.wrap(text).editor;
|
||||||
var editor2 = SpecialPowers.wrap(password).editor;
|
var editor2 = SpecialPowers.wrap(password).editor;
|
||||||
var editor3 = SpecialPowers.wrap(textWithHandlers).editor;
|
|
||||||
var editor4 = SpecialPowers.wrap(passwordWithHandlers).editor;
|
|
||||||
var editor5 = SpecialPowers.wrap(textWithParentHandlers).editor;
|
|
||||||
var editor6 = SpecialPowers.wrap(passwordWithParentHandlers).editor;
|
|
||||||
var editor7 = SpecialPowers.wrap(textarea1).editor;
|
|
||||||
var editor8 = SpecialPowers.wrap(textarea2).editor;
|
|
||||||
var editor9 = SpecialPowers.wrap(textarea3).editor;
|
|
||||||
|
|
||||||
text.focus();
|
text.focus();
|
||||||
|
|
||||||
ok(!editor1.canCopy(),
|
|
||||||
"nsIEditor.canCopy() should return false in <input type=text> with no selection");
|
|
||||||
ok(!editor1.canCut(),
|
|
||||||
"nsIEditor.canCut() should return false in <input type=text> with no selection");
|
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_copy"),
|
|
||||||
"cmd_copy command should be disabled in <input type=text> with no selection");
|
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_cut"),
|
|
||||||
"cmd_cut command should be disabled in <input type=text> with no selection");
|
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_delete"),
|
|
||||||
"cmd_delete command should be disabled in <input type=text> with no selection");
|
|
||||||
|
|
||||||
text.select();
|
text.select();
|
||||||
|
|
||||||
ok(editor1.canCopy(),
|
ok(editor1.canCopy(),
|
||||||
"nsIEditor.canCopy() should return true in <input type=text> with selection");
|
"nsIEditor.canCopy() should return true in <input type=text>");
|
||||||
ok(editor1.canCut(),
|
ok(editor1.canCut(),
|
||||||
"nsIEditor.canCut() should return true in <input type=text> with selection");
|
"nsIEditor.canCut() should return true in <input type=text>");
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_copy"),
|
ok(SpecialPowers.isCommandEnabled(window, "cmd_copy"),
|
||||||
"cmd_copy command should be enabled in <input type=text> with selection");
|
"cmd_copy command should be enabled in <input type=text>");
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_cut"),
|
ok(SpecialPowers.isCommandEnabled(window, "cmd_cut"),
|
||||||
"cmd_cut command should be enabled in <input type=text> with selection");
|
"cmd_cut command should be enabled in <input type=text>");
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_delete"),
|
ok(SpecialPowers.isCommandEnabled(window, "cmd_delete"),
|
||||||
"cmd_delete command should be enabled in <input type=text> with selection");
|
"cmd_delete command should be enabled in <input type=text>");
|
||||||
|
|
||||||
password.focus();
|
password.focus();
|
||||||
|
|
||||||
ok(!editor2.canCopy(),
|
|
||||||
"nsIEditor.canCopy() should return false in <input type=password> with no selection");
|
|
||||||
ok(!editor2.canCut(),
|
|
||||||
"nsIEditor.canCut() should return false in <input type=password> with no selection");
|
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_copy"),
|
|
||||||
"cmd_copy command should be disabled in <input type=password> with no selection");
|
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_cut"),
|
|
||||||
"cmd_cut command should be disabled in <input type=password> with no selection");
|
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_delete"),
|
|
||||||
"cmd_delete command should be disabled in <input type=password> with no selection");
|
|
||||||
|
|
||||||
// Copy and cut commands don't do anything on password fields by default,
|
|
||||||
// so they remain disabled even when there is a selection...
|
|
||||||
password.select();
|
password.select();
|
||||||
|
|
||||||
ok(!editor2.canCopy(),
|
// Copy and cut commands don't do anything on password fields by default,
|
||||||
"nsIEditor.canCopy() should return false in <input type=password> with selection");
|
// but webpages can hook up event handlers to the event, and thus, we have to
|
||||||
ok(!editor2.canCut(),
|
// always keep the cut and copy event enabled in HTML/XHTML documents.
|
||||||
"nsIEditor.canCut() should return false in <input type=password> with selection");
|
ok(editor2.canCopy(),
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_copy"),
|
"nsIEditor.canCopy() should return true in <input type=password>");
|
||||||
"cmd_copy command should be disabled in <input type=password> with selection");
|
ok(editor2.canCut(),
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_cut"),
|
"nsIEditor.canCut() should return true in <input type=password>");
|
||||||
"cmd_cut command should be disabled in <input type=password> with selection");
|
ok(SpecialPowers.isCommandEnabled(window, "cmd_copy"),
|
||||||
// Delete, on the other hand, does apply to password fields.
|
"cmd_copy command should be enabled in <input type=password>");
|
||||||
|
ok(SpecialPowers.isCommandEnabled(window, "cmd_cut"),
|
||||||
|
"cmd_cut command should be enabled in <input type=password>");
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_delete"),
|
ok(SpecialPowers.isCommandEnabled(window, "cmd_delete"),
|
||||||
"cmd_delete command should be enabled in <input type=password with selection>");
|
"cmd_delete command should be enabled in <input type=password>");
|
||||||
|
|
||||||
// ...but webpages can hook up event handlers to cut/copy events, so we have to
|
|
||||||
// keep the cut and copy commands enabled if event handlers are attached,
|
|
||||||
// for both regular edit fields and password fields (even when there's no
|
|
||||||
// selection, as we don't know what the handler might want to do).
|
|
||||||
textWithHandlers.focus();
|
|
||||||
|
|
||||||
ok(editor3.canCopy(),
|
|
||||||
"nsIEditor.canCopy() should return true in <input type=text> with event handler");
|
|
||||||
ok(editor3.canCut(),
|
|
||||||
"nsIEditor.canCut() should return true in <input type=text> with event handler");
|
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_copy"),
|
|
||||||
"cmd_copy command should be enabled in <input type=text> with event handler");
|
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_cut"),
|
|
||||||
"cmd_cut command should be enabled in <input type=text> with event handler");
|
|
||||||
|
|
||||||
passwordWithHandlers.focus();
|
|
||||||
|
|
||||||
ok(editor4.canCopy(),
|
|
||||||
"nsIEditor.canCopy() should return true in <input type=password> with event handler");
|
|
||||||
ok(editor4.canCut(),
|
|
||||||
"nsIEditor.canCut() should return true in <input type=password> with event handler");
|
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_copy"),
|
|
||||||
"cmd_copy command should be enabled in <input type=password> with event handler");
|
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_cut"),
|
|
||||||
"cmd_cut command should be enabled in <input type=password> with event handler");
|
|
||||||
|
|
||||||
// Also check that the commands are enabled if there's a handler on a parent element.
|
|
||||||
textWithParentHandlers.focus();
|
|
||||||
|
|
||||||
ok(editor5.canCopy(),
|
|
||||||
"nsIEditor.canCopy() should return true in <input type=text> with event handler on an ancestor");
|
|
||||||
ok(editor5.canCut(),
|
|
||||||
"nsIEditor.canCut() should return true in <input type=text> with event handler on an ancestor");
|
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_copy"),
|
|
||||||
"cmd_copy command should be enabled in <input type=text> with event handler on an ancestor");
|
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_cut"),
|
|
||||||
"cmd_cut command should be enabled in <input type=text> with event handler on an ancestor");
|
|
||||||
|
|
||||||
passwordWithParentHandlers.focus();
|
|
||||||
|
|
||||||
ok(editor6.canCopy(),
|
|
||||||
"nsIEditor.canCopy() should return true in <input type=password> with event handler on an ancestor");
|
|
||||||
ok(editor6.canCut(),
|
|
||||||
"nsIEditor.canCut() should return true in <input type=password> with event handler on an ancestor");
|
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_copy"),
|
|
||||||
"cmd_copy command should be enabled in <input type=password> with event handler on an ancestor");
|
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_cut"),
|
|
||||||
"cmd_cut command should be enabled in <input type=password> with event handler on an ancestor");
|
|
||||||
|
|
||||||
// TEXTAREA tests
|
|
||||||
|
|
||||||
textarea1.focus();
|
|
||||||
|
|
||||||
ok(!editor7.canCopy(),
|
|
||||||
"nsIEditor.canCopy() should return false in <textarea> with no selection");
|
|
||||||
ok(!editor7.canCut(),
|
|
||||||
"nsIEditor.canCut() should return false in <textarea> with no selection");
|
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_copy"),
|
|
||||||
"cmd_copy command should be disabled in <textarea> with no selection");
|
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_cut"),
|
|
||||||
"cmd_cut command should be disabled in <textarea> with no selection");
|
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_delete"),
|
|
||||||
"cmd_delete command should be disabled in <textarea> with no selection");
|
|
||||||
|
|
||||||
textarea1.select();
|
|
||||||
|
|
||||||
ok(editor7.canCopy(),
|
|
||||||
"nsIEditor.canCopy() should return true in <textarea> with selection");
|
|
||||||
ok(editor7.canCut(),
|
|
||||||
"nsIEditor.canCut() should return true in <textarea> with selection");
|
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_copy"),
|
|
||||||
"cmd_copy command should be enabled in <textarea> with selection");
|
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_cut"),
|
|
||||||
"cmd_cut command should be enabled in <textarea> with selection");
|
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_delete"),
|
|
||||||
"cmd_delete command should be enabled in <textarea> with selection");
|
|
||||||
|
|
||||||
textarea2.focus();
|
|
||||||
|
|
||||||
ok(!editor8.canCopy(),
|
|
||||||
"nsIEditor.canCopy() should return false in <textarea> with only a 'cut' handler");
|
|
||||||
ok(editor8.canCut(),
|
|
||||||
"nsIEditor.canCut() should return true in <textarea> with only a 'cut' handler");
|
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_copy"),
|
|
||||||
"cmd_copy command should be disabled in <textarea> with only a 'cut' handler");
|
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_cut"),
|
|
||||||
"cmd_cut command should be enabled in <textarea> with only a 'cut' handler");
|
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_delete"),
|
|
||||||
"cmd_delete command should be disabled in <textarea> with only a 'cut' handler");
|
|
||||||
|
|
||||||
textarea3.focus();
|
|
||||||
|
|
||||||
ok(editor9.canCopy(),
|
|
||||||
"nsIEditor.canCopy() should return true in <textarea> with only a 'copy' handler on ancestor");
|
|
||||||
ok(!editor9.canCut(),
|
|
||||||
"nsIEditor.canCut() should return false in <textarea> with only a 'copy' handler on ancestor");
|
|
||||||
ok(SpecialPowers.isCommandEnabled(window, "cmd_copy"),
|
|
||||||
"cmd_copy command should be enabled in <textarea> with only a 'copy' handler on ancestor");
|
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_cut"),
|
|
||||||
"cmd_cut command should be disabled in <textarea> with only a 'copy' handler on ancestor");
|
|
||||||
ok(!SpecialPowers.isCommandEnabled(window, "cmd_delete"),
|
|
||||||
"cmd_delete command should be disabled in <textarea> with only a 'copy' handler on ancestor");
|
|
||||||
|
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
}
|
}
|
||||||
@ -208,20 +67,5 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1067255
|
|||||||
|
|
||||||
<input type="text" value="Gonzo says hi" id="text-field" />
|
<input type="text" value="Gonzo says hi" id="text-field" />
|
||||||
<input type="password" value="Jan also" id="password-field" />
|
<input type="password" value="Jan also" id="password-field" />
|
||||||
<input type="text" value="Hi says Gonzo" id="text-field-2" oncut="cut()" oncopy="copy()" ondelete="delete()"/>
|
|
||||||
<input type="password" value="Also Jan" id="password-field-2" oncut="cut()" oncopy="copy()" ondelete="delete()"/>
|
|
||||||
<div oncut="cut()">
|
|
||||||
<ul oncopy="copy()">
|
|
||||||
<li><input type="text" value="Hi again" id="text-field-3"/></li>
|
|
||||||
<li><input type="password" value="And again, hi" id="password-field-3"/></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<textarea id="text-area-1">textarea</textarea>
|
|
||||||
<textarea oncut="cut()" id="text-area-2">textarea with cut handler</textarea>
|
|
||||||
<div oncopy="copy()">
|
|
||||||
<blockquote>
|
|
||||||
<p><textarea id="text-area-3">textarea with copy handler on parent</textarea></p>
|
|
||||||
</blockquote>
|
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -328,7 +328,6 @@ interface nsIEditor : nsISupports
|
|||||||
* HTML/XHTML document.
|
* HTML/XHTML document.
|
||||||
* FYI: Current user in script is only BlueGriffon.
|
* FYI: Current user in script is only BlueGriffon.
|
||||||
*/
|
*/
|
||||||
[can_run_script]
|
|
||||||
boolean canCut();
|
boolean canCut();
|
||||||
|
|
||||||
/** copy the currently selected text, putting it into the OS clipboard
|
/** copy the currently selected text, putting it into the OS clipboard
|
||||||
@ -345,7 +344,6 @@ interface nsIEditor : nsISupports
|
|||||||
* HTML/XHTML document.
|
* HTML/XHTML document.
|
||||||
* FYI: Current user in script is only BlueGriffon.
|
* FYI: Current user in script is only BlueGriffon.
|
||||||
*/
|
*/
|
||||||
[can_run_script]
|
|
||||||
boolean canCopy();
|
boolean canCopy();
|
||||||
|
|
||||||
/** paste the text in the OS clipboard at the cursor position, replacing
|
/** paste the text in the OS clipboard at the cursor position, replacing
|
||||||
|
@ -71,8 +71,6 @@ add_task(async function() {
|
|||||||
is(menu_copy_disabled, false, "menu_copy should be enabled");
|
is(menu_copy_disabled, false, "menu_copy should be enabled");
|
||||||
await new Promise(closeMenu);
|
await new Promise(closeMenu);
|
||||||
|
|
||||||
// When there is no text selected in the contentEditable, we expect the Cut
|
|
||||||
// and Copy commands to be disabled.
|
|
||||||
BrowserTestUtils.loadURI(
|
BrowserTestUtils.loadURI(
|
||||||
browser,
|
browser,
|
||||||
"data:text/html,<div contentEditable='true'>hello!</div>"
|
"data:text/html,<div contentEditable='true'>hello!</div>"
|
||||||
@ -84,28 +82,6 @@ add_task(async function() {
|
|||||||
window.requestAnimationFrame(() => executeSoon(resolve))
|
window.requestAnimationFrame(() => executeSoon(resolve))
|
||||||
);
|
);
|
||||||
await new Promise(openMenu);
|
await new Promise(openMenu);
|
||||||
menu_cut_disabled =
|
|
||||||
menuPopup.querySelector("#menu_cut").getAttribute("disabled") == "true";
|
|
||||||
is(menu_cut_disabled, true, "menu_cut should be disabled");
|
|
||||||
menu_copy_disabled =
|
|
||||||
menuPopup.querySelector("#menu_copy").getAttribute("disabled") ==
|
|
||||||
"true";
|
|
||||||
is(menu_copy_disabled, true, "menu_copy should be disabled");
|
|
||||||
await new Promise(closeMenu);
|
|
||||||
|
|
||||||
// When the text of the contentEditable is selected, the Cut and Copy commands
|
|
||||||
// should be enabled.
|
|
||||||
BrowserTestUtils.loadURI(
|
|
||||||
browser,
|
|
||||||
"data:text/html,<div contentEditable='true'>hello!</div><script>r=new Range;r.selectNodeContents(document.body.firstChild);document.getSelection().addRange(r);</script>"
|
|
||||||
);
|
|
||||||
await BrowserTestUtils.browserLoaded(browser);
|
|
||||||
browser.focus();
|
|
||||||
await new Promise(resolve => waitForFocus(resolve, window));
|
|
||||||
await new Promise(resolve =>
|
|
||||||
window.requestAnimationFrame(() => executeSoon(resolve))
|
|
||||||
);
|
|
||||||
await new Promise(openMenu);
|
|
||||||
menu_cut_disabled =
|
menu_cut_disabled =
|
||||||
menuPopup.querySelector("#menu_cut").getAttribute("disabled") == "true";
|
menuPopup.querySelector("#menu_cut").getAttribute("disabled") == "true";
|
||||||
is(menu_cut_disabled, false, "menu_cut should be enabled");
|
is(menu_cut_disabled, false, "menu_cut should be enabled");
|
||||||
|
Loading…
Reference in New Issue
Block a user