Bug 1534370 part 3. Mark InsertFromTransferable as MOZ_CAN_RUN_SCRIPT. r=masayuki
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 12 Mar 2019 01:55:03 +0000
changeset 521633 879d393e6c581ce67bb748fce870f0325d502112
parent 521632 1289a49488fa7cf67e0bfbb9ed81afc43196e3bf
child 521634 ce5d6bf5dcca9cf3d61955a97b34023f0a870b23
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1534370
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1534370 part 3. Mark InsertFromTransferable as MOZ_CAN_RUN_SCRIPT. r=masayuki Differential Revision: https://phabricator.services.mozilla.com/D23042
accessible/atk/nsMaiInterfaceEditableText.cpp
accessible/generic/HyperTextAccessible.h
accessible/interfaces/nsIAccessibleEditableText.idl
accessible/ipc/other/DocAccessibleChild.cpp
accessible/ipc/other/DocAccessibleChild.h
accessible/windows/ia2/ia2AccessibleEditableText.cpp
accessible/windows/ia2/ia2AccessibleEditableText.h
accessible/xpcom/xpcAccessibleHyperText.cpp
editor/libeditor/EditorBase.cpp
editor/libeditor/EditorCommands.cpp
editor/libeditor/EditorCommands.h
editor/libeditor/HTMLEditor.h
editor/libeditor/HTMLEditorCommands.cpp
editor/libeditor/TextEditor.h
editor/libeditor/TextEditorDataTransfer.cpp
editor/nsIEditor.idl
editor/nsIHTMLEditor.idl
--- a/accessible/atk/nsMaiInterfaceEditableText.cpp
+++ b/accessible/atk/nsMaiInterfaceEditableText.cpp
@@ -86,20 +86,21 @@ static void deleteTextCB(AtkEditableText
     }
 
     text->DeleteText(aStartPos, aEndPos);
   } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
     proxy->DeleteText(aStartPos, aEndPos);
   }
 }
 
+MOZ_CAN_RUN_SCRIPT_BOUNDARY
 static void pasteTextCB(AtkEditableText* aText, gint aPosition) {
   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
   if (accWrap) {
-    HyperTextAccessible* text = accWrap->AsHyperText();
+    RefPtr<HyperTextAccessible> text = accWrap->AsHyperText();
     if (!text || !text->IsTextRole()) {
       return;
     }
 
     text->PasteText(aPosition);
   } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
     proxy->PasteText(aPosition);
   }
--- a/accessible/generic/HyperTextAccessible.h
+++ b/accessible/generic/HyperTextAccessible.h
@@ -401,16 +401,17 @@ class HyperTextAccessible : public Acces
   //////////////////////////////////////////////////////////////////////////////
   // EditableTextAccessible
 
   void ReplaceText(const nsAString& aText);
   void InsertText(const nsAString& aText, int32_t aPosition);
   void CopyText(int32_t aStartPos, int32_t aEndPos);
   void CutText(int32_t aStartPos, int32_t aEndPos);
   void DeleteText(int32_t aStartPos, int32_t aEndPos);
+  MOZ_CAN_RUN_SCRIPT
   void PasteText(int32_t aPosition);
 
   /**
    * Return the editor associated with the accessible.
    * The result may be either TextEditor or HTMLEditor.
    */
   virtual already_AddRefed<TextEditor> GetEditor() const;
 
--- a/accessible/interfaces/nsIAccessibleEditableText.idl
+++ b/accessible/interfaces/nsIAccessibleEditableText.idl
@@ -47,10 +47,11 @@ interface nsIAccessibleEditableText : ns
   void deleteText(in long startPos, in long endPos);
 
   /**
    * Pastes text from the clipboard.
    *
    * @param position - index at which to insert the text from the system
    *                   clipboard into the text represented by this object.
    */
+  [can_run_script]
   void pasteText(in long position);
 };
--- a/accessible/ipc/other/DocAccessibleChild.cpp
+++ b/accessible/ipc/other/DocAccessibleChild.cpp
@@ -577,17 +577,17 @@ mozilla::ipc::IPCResult DocAccessibleChi
     acc->DeleteText(aStartPos, aEndPos);
   }
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult DocAccessibleChild::RecvPasteText(
     const uint64_t& aID, const int32_t& aPosition, bool* aValid) {
-  HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
+  RefPtr<HyperTextAccessible> acc = IdToHyperTextAccessible(aID);
   if (acc && acc->IsTextRole()) {
     *aValid = acc->IsValidOffset(aPosition);
     acc->PasteText(aPosition);
   }
 
   return IPC_OK();
 }
 
--- a/accessible/ipc/other/DocAccessibleChild.h
+++ b/accessible/ipc/other/DocAccessibleChild.h
@@ -201,16 +201,17 @@ class DocAccessibleChild : public DocAcc
                                               const int32_t& aEndPos,
                                               bool* aValid) override;
 
   virtual mozilla::ipc::IPCResult RecvDeleteText(const uint64_t& aID,
                                                  const int32_t& aStartPos,
                                                  const int32_t& aEndPos,
                                                  bool* aValid) override;
 
+  MOZ_CAN_RUN_SCRIPT_BOUNDARY
   virtual mozilla::ipc::IPCResult RecvPasteText(const uint64_t& aID,
                                                 const int32_t& aPosition,
                                                 bool* aValid) override;
 
   virtual mozilla::ipc::IPCResult RecvImagePosition(
       const uint64_t& aID, const uint32_t& aCoordType,
       nsIntPoint* aRetVal) override;
 
--- a/accessible/windows/ia2/ia2AccessibleEditableText.cpp
+++ b/accessible/windows/ia2/ia2AccessibleEditableText.cpp
@@ -72,17 +72,18 @@ ia2AccessibleEditableText::cutText(long 
   textAcc->CutText(aStartOffset, aEndOffset);
   return S_OK;
 }
 
 STDMETHODIMP
 ia2AccessibleEditableText::pasteText(long aOffset) {
   MOZ_ASSERT(!HyperTextProxyFor(this));
 
-  HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
+  RefPtr<HyperTextAccessible> textAcc =
+      static_cast<HyperTextAccessibleWrap*>(this);
   if (textAcc->IsDefunct()) return CO_E_OBJNOTCONNECTED;
 
   if (!textAcc->IsValidOffset(aOffset)) return E_INVALIDARG;
 
   textAcc->PasteText(aOffset);
   return S_OK;
 }
 
--- a/accessible/windows/ia2/ia2AccessibleEditableText.h
+++ b/accessible/windows/ia2/ia2AccessibleEditableText.h
@@ -29,16 +29,17 @@ class ia2AccessibleEditableText : public
   virtual HRESULT STDMETHODCALLTYPE insertText(
       /* [in] */ long offset,
       /* [in] */ BSTR *text);
 
   virtual HRESULT STDMETHODCALLTYPE cutText(
       /* [in] */ long startOffset,
       /* [in] */ long endOffset);
 
+  MOZ_CAN_RUN_SCRIPT_BOUNDARY
   virtual HRESULT STDMETHODCALLTYPE pasteText(
       /* [in] */ long offset);
 
   virtual HRESULT STDMETHODCALLTYPE replaceText(
       /* [in] */ long startOffset,
       /* [in] */ long endOffset,
       /* [in] */ BSTR *text);
 
--- a/accessible/xpcom/xpcAccessibleHyperText.cpp
+++ b/accessible/xpcom/xpcAccessibleHyperText.cpp
@@ -638,17 +638,18 @@ xpcAccessibleHyperText::DeleteText(int32
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleHyperText::PasteText(int32_t aOffset) {
   if (mIntl.IsNull()) return NS_ERROR_FAILURE;
 
   if (mIntl.IsAccessible()) {
-    Intl()->PasteText(aOffset);
+    RefPtr<HyperTextAccessible> acc = Intl();
+    acc->PasteText(aOffset);
   } else {
 #if defined(XP_WIN)
     return NS_ERROR_NOT_IMPLEMENTED;
 #else
     mIntl.AsProxy()->PasteText(aOffset);
 #endif
   }
   return NS_OK;
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -1133,17 +1133,19 @@ EditorBase::Copy() { return NS_ERROR_NOT
 NS_IMETHODIMP
 EditorBase::CanCopy(bool* aCanCut) { return NS_ERROR_NOT_IMPLEMENTED; }
 
 NS_IMETHODIMP
 EditorBase::CanDelete(bool* aCanDelete) { return NS_ERROR_NOT_IMPLEMENTED; }
 
 NS_IMETHODIMP
 EditorBase::Paste(int32_t aClipboardType) {
-  nsresult rv = AsTextEditor()->PasteAsAction(aClipboardType, true);
+  // MOZ_KnownLive because we know "this" must be alive.
+  nsresult rv =
+      MOZ_KnownLive(AsTextEditor())->PasteAsAction(aClipboardType, true);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 EditorBase::PasteTransferable(nsITransferable* aTransferable) {
--- a/editor/libeditor/EditorCommands.cpp
+++ b/editor/libeditor/EditorCommands.cpp
@@ -390,17 +390,19 @@ PasteCommand::IsCommandEnabled(const cha
 NS_IMETHODIMP
 PasteCommand::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
-  return textEditor->PasteAsAction(nsIClipboard::kGlobalClipboard, true);
+  // MOZ_KnownLive because we are holding a stack ref in "editor".
+  return MOZ_KnownLive(textEditor)
+      ->PasteAsAction(nsIClipboard::kGlobalClipboard, true);
 }
 
 NS_IMETHODIMP
 PasteCommand::DoCommandParams(const char* aCommandName,
                               nsICommandParams* aParams,
                               nsISupports* aCommandRefCon) {
   return DoCommand(aCommandName, aCommandRefCon);
 }
@@ -464,17 +466,19 @@ PasteTransferableCommand::DoCommandParam
 
   nsCOMPtr<nsITransferable> trans = do_QueryInterface(supports);
   if (NS_WARN_IF(!trans)) {
     return NS_ERROR_FAILURE;
   }
 
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
-  nsresult rv = textEditor->PasteTransferable(trans);
+  // We know textEditor is known-live here because we are holding a ref to it
+  // via "editor".
+  nsresult rv = MOZ_KnownLive(textEditor)->PasteTransferable(trans);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PasteTransferableCommand::GetCommandStateParams(const char* aCommandName,
@@ -1086,36 +1090,40 @@ NS_IMETHODIMP
 PasteQuotationCommand::DoCommand(const char* aCommandName,
                                  nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
-  nsresult rv = textEditor->PasteAsQuotationAsAction(
-      nsIClipboard::kGlobalClipboard, true);
+  // MOZ_KnownLive because we are holding a stack ref in "editor".
+  nsresult rv =
+      MOZ_KnownLive(textEditor)
+          ->PasteAsQuotationAsAction(nsIClipboard::kGlobalClipboard, true);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PasteQuotationCommand::DoCommandParams(const char* aCommandName,
                                        nsICommandParams* aParams,
                                        nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (!editor) {
     return NS_ERROR_FAILURE;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
-  nsresult rv = textEditor->PasteAsQuotationAsAction(
-      nsIClipboard::kGlobalClipboard, true);
+  // MOZ_KnownLive because we are holding a stack ref in "editor".
+  nsresult rv =
+      MOZ_KnownLive(textEditor)
+          ->PasteAsQuotationAsAction(nsIClipboard::kGlobalClipboard, true);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PasteQuotationCommand::GetCommandStateParams(const char* aCommandName,
--- a/editor/libeditor/EditorCommands.h
+++ b/editor/libeditor/EditorCommands.h
@@ -26,31 +26,34 @@ class EditorCommandBase : public nsICont
  public:
   EditorCommandBase();
 
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD IsCommandEnabled(const char* aCommandName,
                               nsISupports* aCommandRefCon,
                               bool* aIsEnabled) override = 0;
+  MOZ_CAN_RUN_SCRIPT
   NS_IMETHOD DoCommand(const char* aCommandName,
                        nsISupports* aCommandRefCon) override = 0;
 
  protected:
   virtual ~EditorCommandBase() {}
 };
 
 #define NS_DECL_EDITOR_COMMAND(_cmd)                                        \
   class _cmd final : public EditorCommandBase {                             \
    public:                                                                  \
     NS_IMETHOD IsCommandEnabled(const char* aCommandName,                   \
                                 nsISupports* aCommandRefCon,                \
                                 bool* aIsEnabled) override;                 \
+    MOZ_CAN_RUN_SCRIPT                                                      \
     NS_IMETHOD DoCommand(const char* aCommandName,                          \
                          nsISupports* aCommandRefCon) override;             \
+    MOZ_CAN_RUN_SCRIPT                                                      \
     NS_IMETHOD DoCommandParams(const char* aCommandName,                    \
                                nsICommandParams* aParams,                   \
                                nsISupports* aCommandRefCon) override;       \
     NS_IMETHOD GetCommandStateParams(const char* aCommandName,              \
                                      nsICommandParams* aParams,             \
                                      nsISupports* aCommandRefCon) override; \
   };
 
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -129,16 +129,17 @@ class HTMLEditor final : public TextEdit
   virtual nsresult Init(Document& aDoc, Element* aRoot,
                         nsISelectionController* aSelCon, uint32_t aFlags,
                         const nsAString& aValue) override;
   NS_IMETHOD BeginningOfDocument() override;
   NS_IMETHOD SetFlags(uint32_t aFlags) override;
 
   NS_IMETHOD CanPaste(int32_t aSelectionType, bool* aCanPaste) override;
 
+  MOZ_CAN_RUN_SCRIPT
   NS_IMETHOD PasteTransferable(nsITransferable* aTransferable) override;
 
   NS_IMETHOD DeleteNode(nsINode* aNode) override;
 
   NS_IMETHOD InsertLineBreak() override;
 
   virtual nsresult HandleKeyPressEvent(
       WidgetKeyboardEvent* aKeyboardEvent) override;
@@ -155,16 +156,17 @@ class HTMLEditor final : public TextEdit
    * blockquote element.  If the editor is in plaintext mode, will paste the
    * content with appending ">" to start of each line.
    *
    * @param aClipboardType      nsIClipboard::kGlobalClipboard or
    *                            nsIClipboard::kSelectionClipboard.
    * @param aDispatchPasteEvent true if this should dispatch ePaste event
    *                            before pasting.  Otherwise, false.
    */
+  MOZ_CAN_RUN_SCRIPT
   virtual nsresult PasteAsQuotationAsAction(int32_t aClipboardType,
                                             bool aDispatchPasteEvent) override;
 
   /**
    * Can we paste |aTransferable| or, if |aTransferable| is null, will a call
    * to pasteTransferable later possibly succeed if given an instance of
    * nsITransferable then? True if the doc is modifiable, and, if
    * |aTransfeable| is non-null, we have pasteable data in |aTransfeable|.
@@ -1405,16 +1407,17 @@ class HTMLEditor final : public TextEdit
    * This tries to dispatch ePaste event first.  If its defaultPrevent() is
    * called, this does nothing but returns NS_OK.
    *
    * @param aClipboardType      nsIClipboard::kGlobalClipboard or
    *                            nsIClipboard::kSelectionClipboard.
    * @param aDispatchPasteEvent true if this should dispatch ePaste event
    *                            before pasting.  Otherwise, false.
    */
+  MOZ_CAN_RUN_SCRIPT
   nsresult PasteInternal(int32_t aClipboardType, bool aDispatchPasteEvent);
 
   /**
    * InsertAsCitedQuotationInternal() inserts a <blockquote> element whose
    * cite attribute is aCitation and whose content is aQuotedText.
    * Note that this shouldn't be called when IsPlaintextEditor() is true.
    *
    * @param aQuotedText     HTML source if aInsertHTML is true.  Otherwise,
@@ -1945,17 +1948,17 @@ class HTMLEditor final : public TextEdit
                         bool aIsSafe, Document* aSourceDoc,
                         const EditorDOMPoint& aPointToInsert,
                         bool aDoDeleteSelection);
 
   // factored methods for handling insertion of data from transferables
   // (drag&drop or clipboard)
   virtual nsresult PrepareTransferable(nsITransferable** transferable) override;
   nsresult PrepareHTMLTransferable(nsITransferable** transferable);
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY
+  MOZ_CAN_RUN_SCRIPT
   nsresult InsertFromTransferable(nsITransferable* transferable,
                                   Document* aSourceDoc,
                                   const nsAString& aContextStr,
                                   const nsAString& aInfoStr,
                                   bool havePrivateHTMLFlavor,
                                   bool aDoDeleteSelection);
 
   /**
--- a/editor/libeditor/HTMLEditorCommands.cpp
+++ b/editor/libeditor/HTMLEditorCommands.cpp
@@ -137,17 +137,19 @@ PasteNoFormattingCommand::DoCommand(cons
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
   }
   mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
   if (NS_WARN_IF(!htmlEditor)) {
     return NS_ERROR_FAILURE;
   }
-  return htmlEditor->PasteNoFormatting(nsIClipboard::kGlobalClipboard);
+  // Known live because we hold a ref above in "editor"
+  return MOZ_KnownLive(htmlEditor)
+      ->PasteNoFormatting(nsIClipboard::kGlobalClipboard);
 }
 
 NS_IMETHODIMP
 PasteNoFormattingCommand::DoCommandParams(const char* aCommandName,
                                           nsICommandParams* aParams,
                                           nsISupports* refCon) {
   return DoCommand(aCommandName, refCon);
 }
--- a/editor/libeditor/TextEditor.h
+++ b/editor/libeditor/TextEditor.h
@@ -68,16 +68,17 @@ class TextEditor : public EditorBase, pu
   NS_IMETHOD Redo(uint32_t aCount) final;
 
   NS_IMETHOD Cut() override;
   NS_IMETHOD CanCut(bool* aCanCut) override;
   NS_IMETHOD Copy() override;
   NS_IMETHOD CanCopy(bool* aCanCopy) override;
   NS_IMETHOD CanDelete(bool* aCanDelete) override;
   NS_IMETHOD CanPaste(int32_t aSelectionType, bool* aCanPaste) override;
+  MOZ_CAN_RUN_SCRIPT
   NS_IMETHOD PasteTransferable(nsITransferable* aTransferable) override;
 
   NS_IMETHOD OutputToString(const nsAString& aFormatType, uint32_t aFlags,
                             nsAString& aOutputString) override;
 
   /** Can we paste |aTransferable| or, if |aTransferable| is null, will a call
    * to pasteTransferable later possibly succeed if given an instance of
    * nsITransferable then? True if the doc is modifiable, and, if
@@ -114,16 +115,17 @@ class TextEditor : public EditorBase, pu
    * may dispatch ePaste event first.  If its defaultPrevent() is called,
    * this does nothing but returns NS_OK.
    *
    * @param aClipboardType      nsIClipboard::kGlobalClipboard or
    *                            nsIClipboard::kSelectionClipboard.
    * @param aDispatchPasteEvent true if this should dispatch ePaste event
    *                            before pasting.  Otherwise, false.
    */
+  MOZ_CAN_RUN_SCRIPT
   nsresult PasteAsAction(int32_t aClipboardType, bool aDispatchPasteEvent);
 
   /**
    * InsertTextAsAction() inserts aStringToInsert at selection.
    * Although this method is implementation of nsIPlaintextEditor.insertText(),
    * this treats the input is an edit action.  If you'd like to insert text
    * as part of edit action, you probably should use InsertTextAsSubAction().
    *
@@ -136,16 +138,17 @@ class TextEditor : public EditorBase, pu
    * If the editor is TextEditor or in plaintext mode, will paste the content
    * with appending ">" to start of each line.
    *
    * @param aClipboardType      nsIClipboard::kGlobalClipboard or
    *                            nsIClipboard::kSelectionClipboard.
    * @param aDispatchPasteEvent true if this should dispatch ePaste event
    *                            before pasting.  Otherwise, false.
    */
+  MOZ_CAN_RUN_SCRIPT
   virtual nsresult PasteAsQuotationAsAction(int32_t aClipboardType,
                                             bool aDispatchPasteEvent);
 
   /**
    * DeleteSelectionAsAction() removes selection content or content around
    * caret with transactions.  This should be used for handling it as an
    * edit action.  If you'd like to remove selection for preparing to insert
    * something, you probably should use DeleteSelectionAsSubAction().
--- a/editor/libeditor/TextEditorDataTransfer.cpp
+++ b/editor/libeditor/TextEditorDataTransfer.cpp
@@ -364,18 +364,19 @@ nsresult TextEditor::PasteAsAction(int32
   AutoEditActionDataSetter editActionData(*this, EditAction::ePaste);
   if (NS_WARN_IF(!editActionData.CanHandle())) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   if (AsHTMLEditor()) {
     editActionData.InitializeDataTransferWithClipboard(
         SettingDataTransfer::eWithFormat, aClipboardType);
-    nsresult rv =
-        AsHTMLEditor()->PasteInternal(aClipboardType, aDispatchPasteEvent);
+    // MOZ_KnownLive because we know "this" must be alive.
+    nsresult rv = MOZ_KnownLive(AsHTMLEditor())
+                      ->PasteInternal(aClipboardType, aDispatchPasteEvent);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return EditorBase::ToGenericNSResult(rv);
     }
     return NS_OK;
   }
 
   if (aDispatchPasteEvent && !FireClipboardEvent(ePaste, aClipboardType)) {
     return NS_OK;
--- a/editor/nsIEditor.idl
+++ b/editor/nsIEditor.idl
@@ -281,21 +281,23 @@ interface nsIEditor  : nsISupports
 
   /** Can we delete? True if we have a non-collapsed selection.
     */
   boolean canDelete();
 
   /** paste the text in the OS clipboard at the cursor position, replacing
     * the selected text (if any)
     */
+  [can_run_script]
   void paste(in long aSelectionType);
 
   /** Paste the text in |aTransferable| at the cursor position, replacing the
     * selected text (if any).
     */
+  [can_run_script]
   void pasteTransferable(in nsITransferable aTransferable);
 
   /** Can we paste? True if the doc is modifiable, and we have
     * pasteable data in the clipboard.
     */
   boolean canPaste(in long aSelectionType);
 
   /* ------------ Selection methods -------------- */
--- a/editor/nsIHTMLEditor.idl
+++ b/editor/nsIHTMLEditor.idl
@@ -133,16 +133,17 @@ interface nsIHTMLEditor : nsISupports
    */
   void insertHTML(in AString aInputString);
 
 
   /**
     * Paste the text in the OS clipboard at the cursor position, replacing
     * the selected text (if any), but strip out any HTML styles and formatting
     */
+  [can_run_script]
   void pasteNoFormatting(in long aSelectionType);
 
   /**
    *  Rebuild the entire document from source HTML
    *  Needed to be able to edit HEAD and other outside-of-BODY content
    *
    *  @param aSourceString   HTML source string of the entire new document
    */