Bug 1433030 - Initialize nsTransferable::mPrivateData with false draft
authorRob Wu <rob@robwu.nl>
Wed, 07 Mar 2018 10:21:50 +0100
changeset 764128 cb288d057be418bfb5c857526c4f7f33e7825db1
parent 763852 b498494cfac55b99668607280756bee3cb60791a
push id101680
push userbmo:rob@robwu.nl
push dateWed, 07 Mar 2018 09:29:30 +0000
bugs1433030
milestone60.0a1
Bug 1433030 - Initialize nsTransferable::mPrivateData with false Initialize mPrivateData to false by default again, because the change that changed the default value from true to false, i.e. https://hg.mozilla.org/mozilla-central/rev/9e19b58d6494 prevented the clipboard from being backed by the filesystem, as shown at https://bugzilla.mozilla.org/show_bug.cgi?id=1433030#c7 MozReview-Commit-ID: DEw5ETVqab8
widget/nsTransferable.cpp
widget/tests/test_bug1123480.xul
--- a/widget/nsTransferable.cpp
+++ b/widget/nsTransferable.cpp
@@ -189,17 +189,17 @@ DataStruct::ReadCache(nsISupports** aDat
 
 
 //-------------------------------------------------------------------------
 //
 // Transferable constructor
 //
 //-------------------------------------------------------------------------
 nsTransferable::nsTransferable()
-  : mPrivateData(true)
+  : mPrivateData(false)
   , mContentPolicyType(nsIContentPolicy::TYPE_OTHER)
 #ifdef DEBUG
   , mInitialized(false)
 #endif
 {
 }
 
 //-------------------------------------------------------------------------
--- a/widget/tests/test_bug1123480.xul
+++ b/widget/tests/test_bug1123480.xul
@@ -78,18 +78,21 @@ https://bugzilla.mozilla.org/show_bug.cg
     // Sanitize environment
     gClipboardHelper.copyString(SHORT_STRING_NO_CACHE);
 
     var initialFdCount = getClipboardCacheFDCount();
 
     // Overflow a nsTransferable region by using the clipboard helper
     gClipboardHelper.copyString(Ipsum);
 
-    // Undefined private browsing mode should not cache to disk
-    is(getClipboardCacheFDCount(), initialFdCount, "should avoid caching to disk when PBM is undefined");
+    // gClipboardHelper.copyString also puts the data on the selection
+    // clipboard if the platform supports it.
+    var expectedFdDelta = Services.clipboard.supportsSelectionClipboard() ? 2 : 1;
+    // Undefined private browsing mode should cache to disk
+    is(getClipboardCacheFDCount(), initialFdCount + expectedFdDelta, "should cache to disk when PBM is undefined");
 
     // Sanitize environment again.
     gClipboardHelper.copyString(SHORT_STRING_NO_CACHE);
     is(getClipboardCacheFDCount(), initialFdCount, "should have cleared the clipboard data");
 
     // Repeat procedure of plain text selection with private browsing
     // disabled and enabled
     ChromeUtils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");