Back out 4ff7455f6720, "Bug 894736, pass clipboard type to data transfer so that the correct clipboard is used when pasting, r=ehsan" on a CLOSED TREE.
authorJustin Lebar <justin.lebar@gmail.com>
Fri, 02 Aug 2013 10:53:34 -0700
changeset 153459 abeb10e9330edd4c9494c1c6699d643121598280
parent 153458 4aa234138f44be18463d4bf991ab5554c89c07ba
child 153460 3c552ee3aa5e0e1f1156e16ff8b651bcb29785f9
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs894736
milestone25.0a1
backs out4ff7455f6720867482f499ecc839e33ac49dc5f2
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
Back out 4ff7455f6720, "Bug 894736, pass clipboard type to data transfer so that the correct clipboard is used when pasting, r=ehsan" on a CLOSED TREE.
content/base/public/nsCopySupport.h
content/base/src/nsContentUtils.cpp
content/base/src/nsCopySupport.cpp
content/events/src/nsDOMClipboardEvent.cpp
content/events/src/nsDOMDataTransfer.cpp
content/events/src/nsDOMDataTransfer.h
content/events/src/nsEventStateManager.cpp
dom/base/nsGlobalWindowCommands.cpp
dom/tests/mochitest/general/Makefile.in
dom/tests/mochitest/general/test_paste_selection.html
editor/libeditor/html/nsHTMLDataTransfer.cpp
editor/libeditor/text/nsPlaintextDataTransfer.cpp
editor/libeditor/text/nsPlaintextEditor.cpp
editor/libeditor/text/nsPlaintextEditor.h
layout/base/nsDocumentViewer.cpp
testing/specialpowers/content/specialpowersAPI.js
--- a/content/base/public/nsCopySupport.h
+++ b/content/base/public/nsCopySupport.h
@@ -75,19 +75,16 @@ class nsCopySupport
      * point of the selection. If a cut or copy event is not cancelled, the
      * selection is copied to the clipboard and true is returned. Paste events
      * have no default behaviour but true will be returned. It is expected
      * that the caller will execute any needed default paste behaviour. Also,
      * note that this method only copies text to the clipboard, the caller is
      * responsible for removing the content during a cut operation if true is
      * returned.
      *
-     * aClipboardType specifies which clipboard to use, from nsIClipboard.
-     *
      * If the event is cancelled or an error occurs, false will be returned.
      */
     static bool FireClipboardEvent(int32_t aType,
-                                   int32_t aClipboardType,
-                                   nsIPresShell* aPresShell,
-                                   nsISelection* aSelection);
+                                     nsIPresShell* aPresShell,
+                                     nsISelection* aSelection);
 };
 
 #endif
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -4954,17 +4954,17 @@ nsContentUtils::SetDataTransferInEvent(n
 
   nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer;
   dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer));
   if (!initialDataTransfer) {
     // A dataTransfer won't exist when a drag was started by some other
     // means, for instance calling the drag service directly, or a drag
     // from another application. In either case, a new dataTransfer should
     // be created that reflects the data.
-    initialDataTransfer = new nsDOMDataTransfer(aDragEvent->message, true, -1);
+    initialDataTransfer = new nsDOMDataTransfer(aDragEvent->message, true);
 
     NS_ENSURE_TRUE(initialDataTransfer, NS_ERROR_OUT_OF_MEMORY);
 
     // now set it in the drag session so we don't need to create it again
     dragSession->SetDataTransfer(initialDataTransfer);
   }
 
   bool isCrossDomainSubFrameDrop = false;
--- a/content/base/src/nsCopySupport.cpp
+++ b/content/base/src/nsCopySupport.cpp
@@ -568,17 +568,17 @@ nsCopySupport::CanCopy(nsIDocument* aDoc
   NS_ENSURE_TRUE(sel, false);
 
   bool isCollapsed;
   sel->GetIsCollapsed(&isCollapsed);
   return !isCollapsed;
 }
 
 bool
-nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPresShell* aPresShell, nsISelection* aSelection)
+nsCopySupport::FireClipboardEvent(int32_t aType, nsIPresShell* aPresShell, nsISelection* aSelection)
 {
   NS_ASSERTION(aType == NS_CUT || aType == NS_COPY || aType == NS_PASTE,
                "Invalid clipboard event type");
 
   nsCOMPtr<nsIPresShell> presShell = aPresShell;
   if (!presShell)
     return false;
 
@@ -628,17 +628,17 @@ nsCopySupport::FireClipboardEvent(int32_
   if (!nsContentUtils::IsSafeToRunScript())
     return false;
 
   // next, fire the cut, copy or paste event
   // XXXndeakin Bug 844941 - why was a preference added here without a running-in-chrome check?
   bool doDefault = true;
   nsRefPtr<nsDOMDataTransfer> clipboardData;
   if (Preferences::GetBool("dom.event.clipboardevents.enabled", true)) {
-    clipboardData = new nsDOMDataTransfer(aType, aType == NS_PASTE, aClipboardType);
+    clipboardData = new nsDOMDataTransfer(aType, aType == NS_PASTE);
 
     nsEventStatus status = nsEventStatus_eIgnore;
     nsClipboardEvent evt(true, aType);
     evt.clipboardData = clipboardData;
     nsEventDispatcher::Dispatch(content, presShell->GetPresContext(), &evt, nullptr,
                                 &status);
     // If the event was cancelled, don't do the clipboard operation
     doDefault = (status != nsEventStatus_eConsumeNoDefault);
@@ -670,34 +670,34 @@ nsCopySupport::FireClipboardEvent(int32_
   if (doDefault) {
     // get the data from the selection if any
     bool isCollapsed;
     sel->GetIsCollapsed(&isCollapsed);
     if (isCollapsed) {
       return false;
     }
     // call the copy code
-    rv = HTMLCopy(sel, doc, aClipboardType);
+    rv = HTMLCopy(sel, doc, nsIClipboard::kGlobalClipboard);
     if (NS_FAILED(rv)) {
       return false;
     }
   } else if (clipboardData) {
     // check to see if any data was put on the data transfer.
     clipboardData->GetMozItemCount(&count);
     if (count) {
       nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1"));
       NS_ENSURE_TRUE(clipboard, false);
 
       nsCOMPtr<nsITransferable> transferable =
         clipboardData->GetTransferable(0, doc->GetLoadContext());
 
       NS_ENSURE_TRUE(transferable, false);
 
       // put the transferable on the clipboard
-      rv = clipboard->SetData(transferable, nullptr, aClipboardType);
+      rv = clipboard->SetData(transferable, nullptr, nsIClipboard::kGlobalClipboard);
       if (NS_FAILED(rv)) {
         return false;
       }
     }
   }
 
   // Now that we have copied, update the clipboard commands. This should have
   // the effect of updating the enabled state of the paste menu item.
--- a/content/events/src/nsDOMClipboardEvent.cpp
+++ b/content/events/src/nsDOMClipboardEvent.cpp
@@ -2,17 +2,16 @@
 /* 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/. */
 
 #include "nsDOMClipboardEvent.h"
 #include "nsContentUtils.h"
 #include "nsClientRect.h"
 #include "nsDOMDataTransfer.h"
-#include "nsIClipboard.h"
 
 nsDOMClipboardEvent::nsDOMClipboardEvent(mozilla::dom::EventTarget* aOwner,
                                          nsPresContext* aPresContext,
                                          nsClipboardEvent* aEvent)
   : nsDOMEvent(aOwner, aPresContext, aEvent ? aEvent :
                new nsClipboardEvent(false, 0))
 {
   if (aEvent) {
@@ -64,17 +63,17 @@ nsDOMClipboardEvent::Constructor(const m
 
   nsRefPtr<nsDOMDataTransfer> clipboardData;
   if (e->mEventIsInternal) {
     nsClipboardEvent* event = static_cast<nsClipboardEvent*>(e->mEvent);
     if (event) {
       // Always create a clipboardData for the copy event. If this is changed to
       // support other types of events, make sure that read/write privileges are
       // checked properly within nsDOMDataTransfer.
-      clipboardData = new nsDOMDataTransfer(NS_COPY, false, -1);
+      clipboardData = new nsDOMDataTransfer(NS_COPY, false);
       clipboardData->SetData(aParam.mDataType, aParam.mData);
     }
   }
 
   aRv = e->InitClipboardEvent(aType, aParam.mBubbles, aParam.mCancelable,
                               clipboardData);
   e->SetTrusted(trusted);
   return e.forget();
@@ -89,20 +88,20 @@ nsDOMClipboardEvent::GetClipboardData(ns
 
 nsIDOMDataTransfer*
 nsDOMClipboardEvent::GetClipboardData()
 {
   nsClipboardEvent* event = static_cast<nsClipboardEvent*>(mEvent);
 
   if (!event->clipboardData) {
     if (mEventIsInternal) {
-      event->clipboardData = new nsDOMDataTransfer(NS_COPY, false, -1);
+      event->clipboardData = new nsDOMDataTransfer(NS_COPY, false);
     } else {
       event->clipboardData =
-        new nsDOMDataTransfer(event->message, event->message == NS_PASTE, nsIClipboard::kGlobalClipboard);
+        new nsDOMDataTransfer(event->message, event->message == NS_PASTE);
     }
   }
 
   return event->clipboardData;
 }
 
 nsresult NS_NewDOMClipboardEvent(nsIDOMEvent** aInstancePtrResult,
                                  mozilla::dom::EventTarget* aOwner,
--- a/content/events/src/nsDOMDataTransfer.cpp
+++ b/content/events/src/nsDOMDataTransfer.cpp
@@ -58,26 +58,25 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DataTransfer)
 NS_INTERFACE_MAP_END
 
 // the size of the array
 const char nsDOMDataTransfer::sEffects[8][9] = {
   "none", "copy", "move", "copyMove", "link", "copyLink", "linkMove", "all"
 };
 
-nsDOMDataTransfer::nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal, int32_t aClipboardType)
+nsDOMDataTransfer::nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal)
   : mEventType(aEventType),
     mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE),
     mEffectAllowed(nsIDragService::DRAGDROP_ACTION_UNINITIALIZED),
     mCursorState(false),
     mReadOnly(true),
     mIsExternal(aIsExternal),
     mUserCancelled(false),
     mIsCrossDomainSubFrameDrop(false),
-    mClipboardType(aClipboardType),
     mDragImageX(0),
     mDragImageY(0)
 {
   // For these events, we want to be able to add data to the data transfer, so
   // clear the readonly state. Otherwise, the data is already present. For
   // external usage, cache the data from the native clipboard or drag.
   if (aEventType == NS_CUT ||
       aEventType == NS_COPY ||
@@ -94,30 +93,28 @@ nsDOMDataTransfer::nsDOMDataTransfer(uin
 }
 
 nsDOMDataTransfer::nsDOMDataTransfer(uint32_t aEventType,
                                      const uint32_t aEffectAllowed,
                                      bool aCursorState,
                                      bool aIsExternal,
                                      bool aUserCancelled,
                                      bool aIsCrossDomainSubFrameDrop,
-                                     int32_t aClipboardType,
                                      nsTArray<nsTArray<TransferItem> >& aItems,
                                      nsIDOMElement* aDragImage,
                                      uint32_t aDragImageX,
                                      uint32_t aDragImageY)
   : mEventType(aEventType),
     mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE),
     mEffectAllowed(aEffectAllowed),
     mCursorState(aCursorState),
     mReadOnly(true),
     mIsExternal(aIsExternal),
     mUserCancelled(aUserCancelled),
     mIsCrossDomainSubFrameDrop(aIsCrossDomainSubFrameDrop),
-    mClipboardType(aClipboardType),
     mItems(aItems),
     mDragImage(aDragImage),
     mDragImageX(aDragImageX),
     mDragImageY(aDragImageY)
 {
   // The items are copied from aItems into mItems. There is no need to copy
   // the actual data in the items as the data transfer will be read only. The
   // draggesture and dragstart events are the only times when items are
@@ -651,17 +648,17 @@ nsDOMDataTransfer::AddElement(nsIDOMElem
 nsresult
 nsDOMDataTransfer::Clone(uint32_t aEventType, bool aUserCancelled,
                          bool aIsCrossDomainSubFrameDrop,
                          nsIDOMDataTransfer** aNewDataTransfer)
 {
   nsDOMDataTransfer* newDataTransfer =
     new nsDOMDataTransfer(aEventType, mEffectAllowed, mCursorState,
                           mIsExternal, aUserCancelled, aIsCrossDomainSubFrameDrop,
-                          mClipboardType, mItems, mDragImage, mDragImageX, mDragImageY);
+                          mItems, mDragImage, mDragImageX, mDragImageY);
   NS_ENSURE_TRUE(newDataTransfer, NS_ERROR_OUT_OF_MEMORY);
 
   *aNewDataTransfer = newDataTransfer;
   NS_ADDREF(*aNewDataTransfer);
   return NS_OK;
 }
 
 already_AddRefed<nsISupportsArray>
@@ -977,32 +974,33 @@ nsDOMDataTransfer::CacheExternalClipboar
 {
   NS_ASSERTION(mEventType == NS_PASTE, "caching clipboard data for invalid event");
 
   // Called during the constructor for paste events to cache the formats
   // available on the clipboard. As with CacheExternalDragFormats, the
   // data will only be retrieved when needed.
 
   nsCOMPtr<nsIClipboard> clipboard = do_GetService("@mozilla.org/widget/clipboard;1");
-  if (!clipboard || mClipboardType < 0) {
+  if (!clipboard) {
     return;
   }
 
   nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
   nsCOMPtr<nsIPrincipal> sysPrincipal;
   ssm->GetSystemPrincipal(getter_AddRefs(sysPrincipal));
 
   // there isn't a way to get a list of the formats that might be available on
   // all platforms, so just check for the types that can actually be imported
   const char* formats[] = { kFileMime, kHTMLMime, kURLMime, kURLDataMime, kUnicodeMime };
 
   for (uint32_t f = 0; f < mozilla::ArrayLength(formats); ++f) {
     // check each format one at a time
     bool supported;
-    clipboard->HasDataMatchingFlavors(&(formats[f]), 1, mClipboardType, &supported);
+    clipboard->HasDataMatchingFlavors(&(formats[f]), 1,
+                                      nsIClipboard::kGlobalClipboard, &supported);
     // if the format is supported, add an item to the array with null as
     // the data. When retrieved, GetRealData will read the data.
     if (supported) {
       CacheExternalData(formats[f], 0, sysPrincipal);
     }
   }
 }
 
@@ -1033,21 +1031,21 @@ nsDOMDataTransfer::FillInExternalData(Tr
 
   trans->Init(nullptr);
   trans->AddDataFlavor(format);
 
   if (mEventType == NS_PASTE) {
     MOZ_ASSERT(aIndex == 0, "index in clipboard must be 0");
 
     nsCOMPtr<nsIClipboard> clipboard = do_GetService("@mozilla.org/widget/clipboard;1");
-    if (!clipboard || mClipboardType < 0) {
+    if (!clipboard) {
       return;
     }
 
-    clipboard->GetData(trans, mClipboardType);
+    clipboard->GetData(trans, nsIClipboard::kGlobalClipboard);
   } else {
     nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
     if (!dragSession) {
       return;
     }
 
 #ifdef DEBUG
     // Since this is an external drag, the source document will always be null.
--- a/content/events/src/nsDOMDataTransfer.h
+++ b/content/events/src/nsDOMDataTransfer.h
@@ -53,17 +53,16 @@ protected:
   // this constructor is used only by the Clone method to copy the fields as
   // needed to a new data transfer.
   nsDOMDataTransfer(uint32_t aEventType,
                     const uint32_t aEffectAllowed,
                     bool aCursorState,
                     bool aIsExternal,
                     bool aUserCancelled,
                     bool aIsCrossDomainSubFrameDrop,
-                    int32_t aClipboardType,
                     nsTArray<nsTArray<TransferItem> >& aItems,
                     nsIDOMElement* aDragImage,
                     uint32_t aDragImageX,
                     uint32_t aDragImageY);
 
   ~nsDOMDataTransfer()
   {
     if (mFiles) {
@@ -78,20 +77,18 @@ public:
   // Constructor for nsDOMDataTransfer.
   //
   // aEventType is an event constant (such as NS_DRAGDROP_START)
   //
   // aIsExternal must only be true when used to create a dataTransfer for a
   // paste or a drag that was started without using a data transfer. The
   // latter will occur when an external drag occurs, that is, a drag where the
   // source is another application, or a drag is started by calling the drag
-  // service directly. For clipboard operations, aClipboardType indicates
-  // which clipboard to use, from nsIClipboard, or -1 for non-clipboard operations,
-  // or if access to the system clipboard should not be allowed.
-  nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal, int32_t aClipboardType);
+  // service directly.
+  nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal);
 
   void GetDragTarget(nsIDOMElement** aDragTarget)
   {
     *aDragTarget = mDragTarget;
     NS_IF_ADDREF(*aDragTarget);
   }
 
   // a readonly dataTransfer cannot have new data added or existing data removed.
@@ -176,20 +173,16 @@ protected:
 
   // true if the user cancelled the drag. Used only for the dragend event.
   bool mUserCancelled;
 
   // true if this is a cross-domain drop from a subframe where access to the
   // data should be prevented
   bool mIsCrossDomainSubFrameDrop;
 
-  // Indicates which clipboard type to use for clipboard operations. Ignored for
-  // drag and drop.
-  int32_t mClipboardType;
-
   // array of items, each containing an array of format->data pairs
   nsTArray<nsTArray<TransferItem> > mItems;
 
   // array of files, containing only the files present in the dataTransfer
   nsRefPtr<nsDOMFileList> mFiles;
 
   // the target of the drag. The drag and dragend events will fire at this.
   nsCOMPtr<nsIDOMElement> mDragTarget;
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -2022,17 +2022,17 @@ nsEventStateManager::GenerateDragGesture
         DeprecatedAbs(pt.y - mGestureDownPoint.y) > pixelThresholdY) {
       if (mClickHoldContextMenu) {
         // stop the click-hold before we fire off the drag gesture, in case
         // it takes a long time
         KillClickHoldTimer();
       }
 
       nsRefPtr<nsDOMDataTransfer> dataTransfer =
-        new nsDOMDataTransfer(NS_DRAGDROP_START, false, -1);
+        new nsDOMDataTransfer(NS_DRAGDROP_START, false);
       if (!dataTransfer)
         return;
 
       nsCOMPtr<nsISelection> selection;
       nsCOMPtr<nsIContent> eventContent, targetContent;
       mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(eventContent));
       if (eventContent)
         DetermineDragTarget(aPresContext, eventContent, dataTransfer,
--- a/dom/base/nsGlobalWindowCommands.cpp
+++ b/dom/base/nsGlobalWindowCommands.cpp
@@ -20,17 +20,16 @@
 #include "nsIPresShell.h"
 #include "nsIDocShell.h"
 #include "nsISelectionController.h"
 #include "nsIWebNavigation.h"
 #include "nsIContentViewerEdit.h"
 #include "nsIContentViewer.h"
 #include "nsFocusManager.h"
 #include "nsCopySupport.h"
-#include "nsIClipboard.h"
 #include "nsGUIEvent.h"
 #include "mozilla/Attributes.h"
 
 #include "nsIClipboardDragDropHooks.h"
 #include "nsIClipboardDragDropHookList.h"
 
 using namespace mozilla;
 
@@ -361,17 +360,17 @@ nsClipboardCommand::DoCommand(const char
   NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
 
   nsIDocShell *docShell = window->GetDocShell();
   NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
   NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
 
-  nsCopySupport::FireClipboardEvent(NS_COPY, nsIClipboard::kGlobalClipboard, presShell, nullptr);
+  nsCopySupport::FireClipboardEvent(NS_COPY, presShell, nullptr);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsClipboardCommand::GetCommandStateParams(const char *aCommandName,
                                               nsICommandParams *aParams, nsISupports *aCommandContext)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
--- a/dom/tests/mochitest/general/Makefile.in
+++ b/dom/tests/mochitest/general/Makefile.in
@@ -48,17 +48,16 @@ MOCHITEST_FILES = \
 		file_clonewrapper.html \
 		file_moving_nodeList.html \
 		test_performance_now.html \
 		test_interfaces.html \
 		test_idleapi_permissions.html \
 		test_stylesheetPI.html \
 		test_showModalDialog.html \
 		file_showModalDialog.html \
-		test_paste_selection.html \
 		$(NULL)
 
 # Disable this test until bug 795711 is fixed.
 #		test_network_events.html \
 
 MOCHITEST_CHROME_FILES = \
 		test_innerScreen.xul \
 		test_offsets.xul \
deleted file mode 100644
--- a/dom/tests/mochitest/general/test_paste_selection.html
+++ /dev/null
@@ -1,106 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for middle-click to paste selection with paste events</title>
-  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<p id="display"></p>
-<input id="copy-area" value="CLIPBOARD">
-<input id="paste-selection-area" value="" onpaste="pastedSelection(event)">
-<input id="paste-global-area" value="" onpaste="pastedGlobal(event)">
-
-<script>
-
-var supportsSelectionClipboard = SpecialPowers.supportsSelectionClipboard();
-
-function checkSelectionClipboardText(count)
-{
-  if ((!supportsSelectionClipboard ||
-       SpecialPowers.getClipboardData("text/unicode", SpecialPowers.Ci.nsIClipboard.kSelectionClipboard) == "COPY TEXT") &&
-      SpecialPowers.getClipboardData("text/unicode", SpecialPowers.Ci.nsIClipboard.kGlobalClipboard) == "CLIPBOARD") {
-    pasteArea();
-    return;
-  }
-
-  if (count > 10) {
-    ok(false, "could not set clipboards");
-    pasteArea();
-    SimpleTest.finish();
-    return;
-  }
-
-  setTimeout(checkSelectionClipboardText, 5, count + 1);
-}
-
-function selectArea()
-{
-  var copyArea = document.getElementById("copy-area");
-  copyArea.focus();
-  copyArea.select();
-  synthesizeKey("x", { accelKey: true });
-
-  if (supportsSelectionClipboard) {
-    var clipboardHelper = SpecialPowers.Cc["@mozilla.org/widget/clipboardhelper;1"]
-                                       .getService(SpecialPowers.Ci.nsIClipboardHelper);
-    clipboardHelper.copyStringToClipboard("COPY TEXT",
-                                          SpecialPowers.Ci.nsIClipboard.kSelectionClipboard,
-                                          document);
-  }
-
-  setTimeout(checkSelectionClipboardText, 50, 0);
-}
-
-var selectionPasted = false;
-var globalPasted = false;
-
-function pasteArea()
-{
-  var pasteArea = document.getElementById("paste-selection-area");
-  pasteArea.focus();
-  synthesizeMouse(pasteArea, 8, 8, { button: 1 });
-
-  if (supportsSelectionClipboard) {
-    is(document.getElementById("paste-selection-area").value, "COPY TEXT", "data pasted properly from selection");
-    ok(selectionPasted, "selection event fired");
-  }
-  else {
-    is(pasteArea.value, "", "data pasted properly");
-  }
-
-  var pasteArea = document.getElementById("paste-global-area");
-  pasteArea.focus();
-  synthesizeKey("v", { accelKey: true });
-
-  ok(globalPasted, "global event fired");
-  is(document.getElementById("paste-global-area").value, "CLIPBOARD", "data pasted properly from global clipboard");
-  SimpleTest.finish();
-}
-
-function pastedSelection(event)
-{
-  ok(supportsSelectionClipboard, "paste on middle click is valid");
-
-  // The data transfer should contain the selection data, not the global clipboard data.
-  is(event.clipboardData.getData("text/plain"), "COPY TEXT", "data correct in selection data transfer");
-  selectionPasted = true;
-}
-
-function pastedGlobal(event)
-{
-  // The data transfer should contain the global data.
-  is(event.clipboardData.getData("text/plain"), "CLIPBOARD", "data correct in global clipboard data transfer");
-  globalPasted = true;
-}
-
-SimpleTest.waitForExplicitFinish();
-SimpleTest.waitForFocus(selectArea);
-</script>
-
-</pre>
-</body>
-</html>
-
--- a/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -1336,17 +1336,17 @@ bool nsHTMLEditor::HavePrivateHTMLFlavor
     return bHavePrivateHTMLFlavor;
 
   return false;
 }
 
 
 NS_IMETHODIMP nsHTMLEditor::Paste(int32_t aSelectionType)
 {
-  if (!FireClipboardEvent(NS_PASTE, aSelectionType))
+  if (!FireClipboardEvent(NS_PASTE))
     return NS_OK;
 
   // Get Clipboard Service
   nsresult rv;
   nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // find out if we have our internal html flavor on the clipboard.  We don't want to mess
@@ -1417,19 +1417,17 @@ NS_IMETHODIMP nsHTMLEditor::Paste(int32_
     return NS_OK;
 
   return InsertFromTransferable(trans, nullptr, contextStr, infoStr,
                                 nullptr, 0, true);
 }
 
 NS_IMETHODIMP nsHTMLEditor::PasteTransferable(nsITransferable *aTransferable)
 {
-  // Use an invalid value for the clipboard type as data comes from aTransferable
-  // and we don't currently implement a way to put that in the data transfer yet.
-  if (!FireClipboardEvent(NS_PASTE, nsIClipboard::kGlobalClipboard))
+  if (!FireClipboardEvent(NS_PASTE))
     return NS_OK;
 
   // handle transferable hooks
   nsCOMPtr<nsIDOMDocument> domdoc = GetDOMDocument();
   if (!nsEditorHookUtils::DoInsertionHook(domdoc, nullptr, aTransferable))
     return NS_OK;
 
   nsAutoString contextStr, infoStr;
@@ -1437,17 +1435,17 @@ NS_IMETHODIMP nsHTMLEditor::PasteTransfe
                                 nullptr, 0, true);
 }
 
 // 
 // HTML PasteNoFormatting. Ignore any HTML styles and formating in paste source
 //
 NS_IMETHODIMP nsHTMLEditor::PasteNoFormatting(int32_t aSelectionType)
 {
-  if (!FireClipboardEvent(NS_PASTE, aSelectionType))
+  if (!FireClipboardEvent(NS_PASTE))
     return NS_OK;
 
   ForceCompositionEnd();
 
   // Get Clipboard Service
   nsresult rv;
   nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
   NS_ENSURE_SUCCESS(rv, rv);
--- a/editor/libeditor/text/nsPlaintextDataTransfer.cpp
+++ b/editor/libeditor/text/nsPlaintextDataTransfer.cpp
@@ -317,17 +317,17 @@ nsresult nsPlaintextEditor::InsertFromDr
   if (NS_SUCCEEDED(rv))
     ScrollSelectionIntoView(false);
 
   return rv;
 }
 
 NS_IMETHODIMP nsPlaintextEditor::Paste(int32_t aSelectionType)
 {
-  if (!FireClipboardEvent(NS_PASTE, aSelectionType))
+  if (!FireClipboardEvent(NS_PASTE))
     return NS_OK;
 
   // Get Clipboard Service
   nsresult rv;
   nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
   if ( NS_FAILED(rv) )
     return rv;
 
@@ -348,19 +348,17 @@ NS_IMETHODIMP nsPlaintextEditor::Paste(i
     }
   }
 
   return rv;
 }
 
 NS_IMETHODIMP nsPlaintextEditor::PasteTransferable(nsITransferable *aTransferable)
 {
-  // Use an invalid value for the clipboard type as data comes from aTransferable
-  // and we don't currently implement a way to put that in the data transfer yet.
-  if (!FireClipboardEvent(NS_PASTE, -1))
+  if (!FireClipboardEvent(NS_PASTE))
     return NS_OK;
 
   if (!IsModifiable())
     return NS_OK;
 
   // handle transferable hooks
   nsCOMPtr<nsIDOMDocument> domdoc = GetDOMDocument();
   if (!nsEditorHookUtils::DoInsertionHook(domdoc, nullptr, aTransferable))
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -1132,53 +1132,53 @@ nsPlaintextEditor::CanCutOrCopy()
   nsCOMPtr<nsISelection> selection;
   if (NS_FAILED(GetSelection(getter_AddRefs(selection))))
     return false;
 
   return !selection->Collapsed();
 }
 
 bool
-nsPlaintextEditor::FireClipboardEvent(int32_t aType, int32_t aSelectionType)
+nsPlaintextEditor::FireClipboardEvent(int32_t aType)
 {
   if (aType == NS_PASTE)
     ForceCompositionEnd();
 
   nsCOMPtr<nsIPresShell> presShell = GetPresShell();
   NS_ENSURE_TRUE(presShell, false);
 
   nsCOMPtr<nsISelection> selection;
   if (NS_FAILED(GetSelection(getter_AddRefs(selection))))
     return false;
 
-  if (!nsCopySupport::FireClipboardEvent(aType, aSelectionType, presShell, selection))
+  if (!nsCopySupport::FireClipboardEvent(aType, presShell, selection))
     return false;
 
   // If the event handler caused the editor to be destroyed, return false.
   // Otherwise return true to indicate that the event was not cancelled.
   return !mDidPreDestroy;
 }
 
 NS_IMETHODIMP nsPlaintextEditor::Cut()
 {
-  if (FireClipboardEvent(NS_CUT, nsIClipboard::kGlobalClipboard))
+  if (FireClipboardEvent(NS_CUT))
     return DeleteSelection(eNone, eStrip);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsPlaintextEditor::CanCut(bool *aCanCut)
 {
   NS_ENSURE_ARG_POINTER(aCanCut);
   *aCanCut = IsModifiable() && CanCutOrCopy();
   return NS_OK;
 }
 
 NS_IMETHODIMP nsPlaintextEditor::Copy()
 {
-  FireClipboardEvent(NS_COPY, nsIClipboard::kGlobalClipboard);
+  FireClipboardEvent(NS_COPY);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsPlaintextEditor::CanCopy(bool *aCanCopy)
 {
   NS_ENSURE_ARG_POINTER(aCanCopy);
   *aCanCopy = CanCutOrCopy();
   return NS_OK;
--- a/editor/libeditor/text/nsPlaintextEditor.h
+++ b/editor/libeditor/text/nsPlaintextEditor.h
@@ -191,17 +191,17 @@ protected:
 
   /** shared outputstring; returns whether selection is collapsed and resulting string */
   nsresult SharedOutputString(uint32_t aFlags, bool* aIsCollapsed, nsAString& aResult);
 
   /* small utility routine to test the eEditorReadonly bit */
   bool IsModifiable();
 
   bool CanCutOrCopy();
-  bool FireClipboardEvent(int32_t aType, int32_t aSelectionType);
+  bool FireClipboardEvent(int32_t aType);
 
   bool UpdateMetaCharset(nsIDOMDocument* aDocument,
                          const nsACString& aCharacterSet);
 
 // Data members
 protected:
 
   nsCOMPtr<nsIEditRules>        mRules;
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -2485,17 +2485,17 @@ NS_IMETHODIMP nsDocumentViewer::SelectAl
   if (NS_FAILED(rv)) return rv;
 
   rv = selection->SelectAllChildren(bodyNode);
   return rv;
 }
 
 NS_IMETHODIMP nsDocumentViewer::CopySelection()
 {
-  nsCopySupport::FireClipboardEvent(NS_COPY, nsIClipboard::kGlobalClipboard, mPresShell, nullptr);
+  nsCopySupport::FireClipboardEvent(NS_COPY, mPresShell, nullptr);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsDocumentViewer::CopyLinkLocation()
 {
   NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_INITIALIZED);
   nsCOMPtr<nsIDOMNode> node;
   GetPopupLinkNode(getter_AddRefs(node));
--- a/testing/specialpowers/content/specialpowersAPI.js
+++ b/testing/specialpowers/content/specialpowersAPI.js
@@ -1341,29 +1341,27 @@ SpecialPowersAPI.prototype = {
   focus: function(aWindow) {
     // This is called inside TestRunner._makeIframe without aWindow, because of assertions in oop mochitests
     // With aWindow, it is called in SimpleTest.waitForFocus to allow popup window opener focus switching
     if (aWindow)
       aWindow.focus();
     sendAsyncMessage("SpecialPowers.Focus", {});
   },
 
-  getClipboardData: function(flavor, whichClipboard) {
+  getClipboardData: function(flavor) {
     if (this._cb == null)
       this._cb = Components.classes["@mozilla.org/widget/clipboard;1"].
                             getService(Components.interfaces.nsIClipboard);
-    if (whichClipboard === undefined)
-      whichClipboard = this._cb.kGlobalClipboard;
 
     var xferable = Components.classes["@mozilla.org/widget/transferable;1"].
                    createInstance(Components.interfaces.nsITransferable);
     xferable.init(this._getDocShell(content.window)
                       .QueryInterface(Components.interfaces.nsILoadContext));
     xferable.addDataFlavor(flavor);
-    this._cb.getData(xferable, whichClipboard);
+    this._cb.getData(xferable, this._cb.kGlobalClipboard);
     var data = {};
     try {
       xferable.getTransferData(flavor, data, {});
     } catch (e) {}
     data = data.value || null;
     if (data == null)
       return "";