Bug 825196 - Convert HTMLInputElement to WebIDL. r=Ms2ger

This commit is contained in:
Andrea Marchesini 2013-03-28 15:41:32 -04:00
parent 77ae8010d9
commit 65e4f3628b
15 changed files with 986 additions and 326 deletions

File diff suppressed because it is too large Load Diff

View File

@ -63,6 +63,10 @@ class HTMLInputElement : public nsGenericHTMLFormElement,
{
public:
using nsIConstraintValidation::GetValidationMessage;
using nsIConstraintValidation::CheckValidity;
using nsIConstraintValidation::WillValidate;
using nsIConstraintValidation::Validity;
using nsGenericHTMLFormElement::GetForm;
HTMLInputElement(already_AddRefed<nsINodeInfo> aNodeInfo,
mozilla::dom::FromParser aFromParser);
@ -167,7 +171,12 @@ public:
NS_IMETHOD_(bool) HasCachedSelection();
void GetDisplayFileName(nsAString& aFileName) const;
const nsCOMArray<nsIDOMFile>& GetFiles() const;
const nsCOMArray<nsIDOMFile>& GetFilesInternal() const
{
return mFiles;
}
void SetFiles(const nsCOMArray<nsIDOMFile>& aFiles, bool aSetValueChanged);
void SetFiles(nsIDOMFileList* aFiles, bool aSetValueChanged);
@ -278,13 +287,6 @@ public:
*/
void UpdateValidityUIBits(bool aIsFocused);
bool DefaultChecked() const {
return HasAttr(kNameSpaceID_None, nsGkAtoms::checked);
}
bool Indeterminate() const { return mIndeterminate; }
bool Checked() const { return mChecked; }
/**
* Fires change event if mFocusedValue and current value held are unequal.
*/
@ -318,7 +320,319 @@ public:
*/
double GetMaximum() const;
// WebIDL
// XPCOM GetAccept() is OK
void SetAccept(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::accept, aValue, aRv);
}
// XPCOM GetAlt() is OK
void SetAlt(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::alt, aValue, aRv);
}
// XPCOM GetAutocomplete() is OK
void SetAutocomplete(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::autocomplete, aValue, aRv);
}
bool Autofocus() const
{
return GetBoolAttr(nsGkAtoms::autofocus);
}
void SetAutofocus(bool aValue, ErrorResult& aRv)
{
SetHTMLBoolAttr(nsGkAtoms::autofocus, aValue, aRv);
}
bool DefaultChecked() const
{
return HasAttr(kNameSpaceID_None, nsGkAtoms::checked);
}
void SetDefaultChecked(bool aValue, ErrorResult& aRv)
{
SetHTMLBoolAttr(nsGkAtoms::checked, aValue, aRv);
}
bool Checked() const
{
return mChecked;
}
// XPCOM SetChecked() is OK
bool Disabled() const
{
return GetBoolAttr(nsGkAtoms::disabled);
}
void SetDisabled(bool aValue,ErrorResult& aRv)
{
SetHTMLBoolAttr(nsGkAtoms::disabled, aValue, aRv);
}
// XPCOM GetForm() is OK
nsDOMFileList* GetFiles();
// XPCOM GetFormAction() is OK
void SetFormAction(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::formaction, aValue, aRv);
}
// XPCOM GetFormEnctype() is OK
void SetFormEnctype(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::formenctype, aValue, aRv);
}
// XPCOM GetFormMethod() is OK
void SetFormMethod(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::formmethod, aValue, aRv);
}
bool FormNoValidate() const
{
return GetBoolAttr(nsGkAtoms::formnovalidate);
}
void SetFormNoValidate(bool aValue, ErrorResult& aRv)
{
SetHTMLBoolAttr(nsGkAtoms::formnovalidate, aValue, aRv);
}
// XPCOM GetFormTarget() is OK
void SetFormTarget(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::formtarget, aValue, aRv);
}
uint32_t Height();
void SetHeight(uint32_t aValue, ErrorResult& aRv)
{
aRv = nsGenericHTMLElement::SetUnsignedIntAttr(nsGkAtoms::height, aValue);
}
bool Indeterminate() const
{
return mIndeterminate;
}
// XPCOM SetIndeterminate() is OK
// XPCOM GetInputMode() is OK
void SetInputMode(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::inputmode, aValue, aRv);
}
nsGenericHTMLElement* GetList() const;
// XPCOM GetMax() is OK
void SetMax(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::max, aValue, aRv);
}
int32_t MaxLength() const
{
return GetIntAttr(nsGkAtoms::maxlength, -1);
}
void SetMaxLength(int32_t aValue, ErrorResult& aRv)
{
if (aValue < 0) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return;
}
SetHTMLIntAttr(nsGkAtoms::maxlength, aValue, aRv);
}
// XPCOM GetMin() is OK
void SetMin(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::min, aValue, aRv);
}
bool Multiple() const
{
return GetBoolAttr(nsGkAtoms::multiple);
}
void SetMultiple(bool aValue, ErrorResult& aRv)
{
SetHTMLBoolAttr(nsGkAtoms::multiple, aValue, aRv);
}
// XPCOM GetName() is OK
void SetName(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::name, aValue, aRv);
}
// XPCOM GetPattern() is OK
void SetPattern(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::pattern, aValue, aRv);
}
// XPCOM GetPlaceholder() is OK
void SetPlaceholder(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::placeholder, aValue, aRv);
}
bool ReadOnly() const
{
return GetBoolAttr(nsGkAtoms::readonly);
}
void SetReadOnly(bool aValue, ErrorResult& aRv)
{
SetHTMLBoolAttr(nsGkAtoms::readonly, aValue, aRv);
}
bool Required() const
{
return GetBoolAttr(nsGkAtoms::required);
}
void SetRequired(bool aValue, ErrorResult& aRv)
{
SetHTMLBoolAttr(nsGkAtoms::required, aValue, aRv);
}
uint32_t Size()
{
uint32_t value;
GetUnsignedIntAttr(nsGkAtoms::size, DEFAULT_COLS, &value);
return value;
}
void SetSize(uint32_t aValue, ErrorResult& aRv)
{
if (aValue == 0) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return;
}
SetHTMLUnsignedIntAttr(nsGkAtoms::size, aValue, aRv);
}
// XPCOM GetSrc() is OK
void SetSrc(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::src, aValue, aRv);
}
// XPCOM GetStep() is OK
void SetStep(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::step, aValue, aRv);
}
// XPCOM GetType() is OK
void SetType(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::type, aValue, aRv);
}
// XPCOM GetDefaultValue() is OK
void SetDefaultValue(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::value, aValue, aRv);
}
// XPCOM GetValue() is OK
void SetValue(const nsAString& aValue, ErrorResult& aRv);
JS::Value GetValueAsDate(JSContext* aCx, ErrorResult& aRv);
void SetValueAsDate(JSContext* aCx, JS::Value aValue, ErrorResult& aRv);
double ValueAsNumber() const
{
return DoesValueAsNumberApply() ? GetValueAsDouble()
: MOZ_DOUBLE_NaN();
}
void SetValueAsNumber(double aValue, ErrorResult& aRv);
uint32_t Width();
void SetWidth(uint32_t aValue, ErrorResult& aRv)
{
aRv = nsGenericHTMLElement::SetUnsignedIntAttr(nsGkAtoms::width, aValue);
}
void StepUp(const Optional< int32_t >& n, ErrorResult& aRv)
{
aRv = ApplyStep(n.WasPassed() ? n.Value() : 1);
}
void StepDown(const Optional< int32_t >& n, ErrorResult& aRv)
{
aRv = ApplyStep(n.WasPassed() ? -n.Value() : -1);
}
void GetValidationMessage(nsAString& aValidationMessage, ErrorResult& aRv);
// XPCOM GetCustomVisibility() is OK
// XPCOM Select() is OK
int32_t GetSelectionStart(ErrorResult& aRv);
void SetSelectionStart(int32_t aValue, ErrorResult& aRv);
int32_t GetSelectionEnd(ErrorResult& aRv);
void SetSelectionEnd(int32_t aValue, ErrorResult& aRv);
void GetSelectionDirection(nsAString& aValue, ErrorResult& aRv);
void SetSelectionDirection(const nsAString& aValue, ErrorResult& aRv);
void SetSelectionRange(int32_t aStart, int32_t aEnd,
const Optional< nsAString >& direction,
ErrorResult& aRv);
// XPCOM GetAlign() is OK
void SetAlign(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::align, aValue, aRv);
}
// XPCOM GetUseMap() is OK
void SetUseMap(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::usemap, aValue, aRv);
}
nsIControllers* GetControllers(ErrorResult& aRv);
int32_t GetTextLength(ErrorResult& aRv);
void MozGetFileNameArray(nsTArray< nsString >& aFileNames);
void MozSetFileNameArray(const Sequence< nsString >& aFileNames);
bool MozIsTextField(bool aExcludePassword);
nsIEditor* GetEditor();
// XPCOM SetUserInput() is OK
// XPCOM GetPhonetic() is OK
protected:
virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
// Pull IsSingleLineTextControl into our scope, otherwise it'd be hidden
// by the nsITextControlElement version.
using nsGenericHTMLFormElement::IsSingleLineTextControl;
@ -404,8 +718,8 @@ protected:
SetFiles(files, aSetValueChanged);
}
nsresult SetIndeterminateInternal(bool aValue,
bool aShouldInvalidate);
void SetIndeterminateInternal(bool aValue,
bool aShouldInvalidate);
nsresult GetSelectionRange(int32_t* aSelectionStart, int32_t* aSelectionEnd);

View File

@ -61,7 +61,6 @@ function reflectString(aParameters)
// TODO: remove this ugly hack when null stringification will work as expected.
var todoAttrs = {
form: [ "acceptCharset", "name", "target" ],
input: [ "accept", "alt", "formTarget", "max", "min", "name", "pattern", "placeholder", "step", "defaultValue" ]
};
if (!(element.localName in todoAttrs) || todoAttrs[element.localName].indexOf(idlAttr) == -1) {
if (treatNullAs == "EmptyString") {

View File

@ -23,12 +23,11 @@ var inputChange = 0;
var textareaChange = 0;
function testUserInput() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var input = document.getElementById("input");
var textarea = SpecialPowers.wrap(document.getElementById("textarea"));
input.focus();
input.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).setUserInput("foo");
SpecialPowers.wrap(input).setUserInput("foo");
input.blur();
is(inputChange, 1, "Input element should have got one change event.");
@ -42,7 +41,7 @@ function testUserInput() {
is(inputChange, 1,
"Change event dispatched when setting the value of the input element (2).");
input.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).setUserInput("foo");
SpecialPowers.wrap(input).setUserInput("foo");
is(inputChange, 1,
"Change event dispatched when input element doesn't have focus.");

View File

@ -411,24 +411,22 @@ var myFile1, myFile2, emptyFile;
multiFile = [basePath + "file_formSubmission_text.txt",
basePath + "file_formSubmission_img.jpg"];
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var addList = document.getElementsByClassName("setfile");
let i = 0;
var input;
while (input = addList[i++]) {
if (input.classList.contains("multi")) {
input.mozSetFileNameArray(multiFile, multiFile.length);
SpecialPowers.wrap(input).mozSetFileNameArray(multiFile, multiFile.length);
}
else {
input.value = singleFile;
SpecialPowers.wrap(input).value = singleFile;
}
}
input = document.createElement("input");
input.type = "file";
input.multiple = true;
input.mozSetFileNameArray(multiFile, multiFile.length);
SpecialPowers.wrap(input).mozSetFileNameArray(multiFile, multiFile.length);
myFile1 = input.files[0];
myFile2 = input.files[1];
is(myFile1.size, 20, "File1 size");

View File

@ -1382,6 +1382,7 @@ addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSou
addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=True)
addExternalIface('MozXULTemplateBuilder', nativeType='nsIXULTemplateBuilder')
addExternalIface('MozNamedAttrMap')
addExternalIface('nsIControllers', nativeType='nsIControllers')
addExternalIface('nsIStreamListener', nativeType='nsIStreamListener', notflattened=True)
addExternalIface('nsISupports', nativeType='nsISupports')
addExternalIface('nsIEditor', nativeType='nsIEditor', notflattened=True)

View File

@ -11,8 +11,9 @@ interface nsIEditor;
* This interface is implemented by elements which have inner editable content,
* such as HTML input and textarea.
*
* Please make sure to update the HTMLTextAreaElement Web IDL interface to
* mirror this interface when changing it.
* Please make sure to update the HTMLTextAreaElement and HTMLInputElement
* Web IDL interfaces to mirror this interface when changing it.
*
*/
[scriptable, uuid(b33eb56c-3120-418c-892b-774b00c7dde8)]

View File

@ -0,0 +1,175 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://www.whatwg.org/specs/web-apps/current-work/#the-input-element
* http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
interface nsIControllers;
interface HTMLInputElement : HTMLElement {
[Pure, SetterThrows]
attribute DOMString accept;
[Pure, SetterThrows]
attribute DOMString alt;
[Pure, SetterThrows]
attribute DOMString autocomplete;
[Pure, SetterThrows]
attribute boolean autofocus;
[Pure, SetterThrows]
attribute boolean defaultChecked;
[Pure]
attribute boolean checked;
// Bug 850337 - attribute DOMString dirName;
[Pure, SetterThrows]
attribute boolean disabled;
readonly attribute HTMLFormElement? form;
[Pure]
readonly attribute FileList? files;
[Pure, SetterThrows]
attribute DOMString formAction;
[Pure, SetterThrows]
attribute DOMString formEnctype;
[Pure, SetterThrows]
attribute DOMString formMethod;
[Pure, SetterThrows]
attribute boolean formNoValidate;
[Pure, SetterThrows]
attribute DOMString formTarget;
[Pure, SetterThrows]
attribute unsigned long height;
[Pure]
attribute boolean indeterminate;
[Pure, SetterThrows]
attribute DOMString inputMode;
[Pure]
readonly attribute HTMLElement? list;
[Pure, SetterThrows]
attribute DOMString max;
[Pure, SetterThrows]
attribute long maxLength;
[Pure, SetterThrows]
attribute DOMString min;
[Pure, SetterThrows]
attribute boolean multiple;
[Pure, SetterThrows]
attribute DOMString name;
[Pure, SetterThrows]
attribute DOMString pattern;
[Pure, SetterThrows]
attribute DOMString placeholder;
[Pure, SetterThrows]
attribute boolean readOnly;
[Pure, SetterThrows]
attribute boolean required;
[Pure, SetterThrows]
attribute unsigned long size;
[Pure, SetterThrows]
attribute DOMString src;
[Pure, SetterThrows]
attribute DOMString step;
[Pure, SetterThrows]
attribute DOMString type;
[Pure, SetterThrows]
attribute DOMString defaultValue;
[Pure, TreatNullAs=EmptyString, SetterThrows]
attribute DOMString value;
// Bug 742206 - any to Date?
[Throws]
attribute any valueAsDate;
[Pure, SetterThrows]
attribute unrestricted double valueAsNumber;
attribute unsigned long width;
[Throws]
void stepUp(optional long n);
[Throws]
void stepDown(optional long n);
[Pure]
readonly attribute boolean willValidate;
[Pure]
readonly attribute ValidityState validity;
[GetterThrows]
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(DOMString error);
// Bug 850365 readonly attribute NodeList labels;
void select();
[Throws]
// TODO: unsigned vs signed
attribute long selectionStart;
[Throws]
attribute long selectionEnd;
[Throws]
attribute DOMString selectionDirection;
// Bug 850364 void setRangeText(DOMString replacement);
// Bug 850364 setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode);
// also has obsolete members
};
partial interface HTMLInputElement {
[Pure, SetterThrows]
attribute DOMString align;
[Pure, SetterThrows]
attribute DOMString useMap;
};
// Mozilla extensions
partial interface HTMLInputElement {
[Throws]
void setSelectionRange(long start, long end, optional DOMString direction);
[GetterThrows]
readonly attribute nsIControllers controllers;
[GetterThrows]
readonly attribute long textLength;
[ChromeOnly]
sequence<DOMString> mozGetFileNameArray();
[ChromeOnly]
void mozSetFileNameArray(sequence<DOMString> fileNames);
/**
* This non-standard method prevents to check types manually to know if the
* element is a text field.
*/
boolean mozIsTextField(boolean aExcludePassword);
};
partial interface HTMLInputElement {
// Mirrored chrome-only nsIDOMNSEditableElement methods. Please make sure
// to update this list if nsIDOMNSEditableElement changes.
[Pure, ChromeOnly]
readonly attribute nsIEditor? editor;
// This is similar to set .value on nsIDOMInput/TextAreaElements, but
// handling of the value change is closer to the normal user input, so
// 'change' event for example will be dispatched when focusing out the
// element.
[ChromeOnly]
void setUserInput(DOMString input);
};
[NoInterfaceObject]
interface MozPhonetic {
[Pure, ChromeOnly]
readonly attribute DOMString phonetic;
};
HTMLInputElement implements MozImageLoadingContent;
HTMLInputElement implements MozPhonetic;

View File

@ -95,6 +95,7 @@ webidl_files = \
HTMLHtmlElement.webidl \
HTMLIFrameElement.webidl \
HTMLImageElement.webidl \
HTMLInputElement.webidl \
HTMLLabelElement.webidl \
HTMLLegendElement.webidl \
HTMLLIElement.webidl \

View File

@ -33,11 +33,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=502673
listener.prototype =
{
NotifyDocumentWillBeDestroyed: function () {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
if (this.input instanceof
Components.interfaces.nsIDOMNSEditableElement) {
var editor = this.input.editor;
if (this.input instanceof SpecialPowers.Ci.nsIDOMNSEditableElement) {
var editor = SpecialPowers.wrap(this.input).editor;
editor.removeDocumentStateListener(this);
}
},
@ -46,30 +43,25 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=502673
},
NotifyDocumentStateChanged: function (aNowDirty) {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
if (this.input instanceof
Components.interfaces.nsIDOMNSEditableElement) {
var editor = this.input.editor;
if (this.input instanceof SpecialPowers.Ci.nsIDOMNSEditableElement) {
var editor = SpecialPowers.wrap(this.input).editor;
editor.removeDocumentStateListener(this);
}
},
QueryInterface: function(iid) {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
if (iid.equals(Components.interfaces.nsIDocumentStateListener) ||
iid.equals(Components.interfaces.nsISupports))
if (iid.equals(SpecialPowers.Ci.nsIDocumentStateListener) ||
iid.equals(SpecialPowers.Ci.nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE;
},
};
function doTest() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var input = document.getElementById("ip");
if (input instanceof Components.interfaces.nsIDOMNSEditableElement) {
if (input instanceof SpecialPowers.Ci.nsIDOMNSEditableElement) {
// Add multiple listeners to the same editor
var editor = input.editor;
var editor = SpecialPowers.wrap(input).editor;
var listener1 = new listener();
listener1.input = input;
var listener2 = new listener();

View File

@ -31,9 +31,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=471722
var t1 = $("t1");
var editor = null;
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
if (t1 instanceof Components.interfaces.nsIDOMNSEditableElement)
editor = t1.editor;
if (t1 instanceof SpecialPowers.Ci.nsIDOMNSEditableElement)
editor = SpecialPowers.wrap(t1).editor;
ok(editor, "able to get editor for the element");
t1.focus();
t1.select();

View File

@ -21,13 +21,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=602130
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var i = document.createElement("input");
document.body.appendChild(i);
i.QueryInterface(Components.interfaces.nsIDOMNSEditableElement);
SpecialPowers.wrap(i).QueryInterface(SpecialPowers.Ci.nsIDOMNSEditableElement);
i.select();
i.focus();
is(i.editor.transactionManager.numberOfUndoItems, 0,
is(SpecialPowers.wrap(i).editor.transactionManager.numberOfUndoItems, 0,
"The number of undo items should be 0 after initing the editor");
i.style.display = "none";
document.offsetWidth;
@ -35,7 +34,7 @@ addLoadEvent(function() {
document.offsetWidth;
i.select();
i.focus();
is(i.editor.transactionManager.numberOfUndoItems, 0,
is(SpecialPowers.wrap(i).editor.transactionManager.numberOfUndoItems, 0,
"The number of undo items should be 0 after re-initing the editor");
SimpleTest.finish();
});

View File

@ -19,13 +19,11 @@
var t = $("target");
doIs(t.value, "Test", "Typing should work");
(function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
t.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor.undo(1);
SpecialPowers.wrap(t).QueryInterface(SpecialPowers.Ci.nsIDOMNSEditableElement).editor.undo(1);
})()
doIs(t.value, "", "Undo should work");
(function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
t.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor.redo(1);
SpecialPowers.wrap(t).QueryInterface(SpecialPowers.Ci.nsIDOMNSEditableElement).editor.redo(1);
})()
doIs(t.value, "Test", "Redo should work");
window.parent.postMessage("f", "*");

View File

@ -42,11 +42,10 @@ addLoadEvent(function() {
function synthesizeDropText(aElement, aText)
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var Ci = Components.interfaces;
var editor = aElement.QueryInterface(Ci.nsIDOMNSEditableElement)
.editor
.QueryInterface(Ci.nsIPlaintextEditor);
var editor = SpecialPowers.wrap(aElement)
.QueryInterface(SpecialPowers.Ci.nsIDOMNSEditableElement)
.editor
.QueryInterface(SpecialPowers.Ci.nsIPlaintextEditor);
editor.insertText(aText);
}

View File

@ -79,13 +79,10 @@ var textarea = SpecialPowers.wrap(document.getElementById("textarea"));
function test()
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
function getSelectionForEditor(aEditorElement)
{
const nsIDOMNSEditableElement =
Components.interfaces.nsIDOMNSEditableElement;
return aEditorElement.QueryInterface(nsIDOMNSEditableElement).editor.selection;
const nsIDOMNSEditableElement = SpecialPowers.Ci.nsIDOMNSEditableElement;
return SpecialPowers.wrap(aEditorElement).editor.selection;
}
function clear()