mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-04 16:15:25 +00:00
f4b598bf08
This patch does the following: * It adds nsITransferable::Init(nsILoadContext*). The load context might be null, which means that the transferable is non-private, but if it's non-null, we extract the boolean value for the privacy mode and store it in the transferable. * It adds checks in debug builds to make sure that Init is always called, in form of fatal assertions. * It adds nsIDOMDocument* agruments to nsIClipboardHelper methods which represent the document that the string is coming from. nsIClipboardHelper implementation internally gets the nsILoadContext from that and passes it on to the transferable upon creation. The reason that I did this was that nsIClipboardHelper is supposed to be a high-level helper, and in most of its call sites, we have easy access to a document object. * It modifies all of the call sites of the above interfaces according to this change. * It adds a GetLoadContext helper to nsIDocument to help with changing the call sites.
56 lines
1.8 KiB
JavaScript
56 lines
1.8 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
const middleMousePastePref = "middlemouse.contentLoadURL";
|
|
const autoScrollPref = "general.autoScroll";
|
|
function test() {
|
|
waitForExplicitFinish();
|
|
|
|
Services.prefs.setBoolPref(middleMousePastePref, true);
|
|
Services.prefs.setBoolPref(autoScrollPref, false);
|
|
let tab = gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
registerCleanupFunction(function () {
|
|
Services.prefs.clearUserPref(middleMousePastePref);
|
|
Services.prefs.clearUserPref(autoScrollPref);
|
|
gBrowser.removeTab(tab);
|
|
});
|
|
|
|
addPageShowListener(function () {
|
|
let pagePrincipal = gBrowser.contentPrincipal;
|
|
|
|
// copy javascript URI to the clipboard
|
|
let url = "javascript:1+1";
|
|
waitForClipboard(url,
|
|
function() {
|
|
Components.classes["@mozilla.org/widget/clipboardhelper;1"]
|
|
.getService(Components.interfaces.nsIClipboardHelper)
|
|
.copyString(url, document);
|
|
},
|
|
function () {
|
|
// Middle click on the content area
|
|
info("Middle clicking");
|
|
EventUtils.sendMouseEvent({type: "click", button: 1}, gBrowser);
|
|
},
|
|
function() {
|
|
ok(false, "Failed to copy URL to the clipboard");
|
|
finish();
|
|
}
|
|
);
|
|
|
|
addPageShowListener(function () {
|
|
is(gBrowser.currentURI.spec, url, "url loaded by middle click");
|
|
ok(!gBrowser.contentPrincipal.equals(pagePrincipal),
|
|
"middle click load of " + url + " should produce a page with a different principal");
|
|
finish();
|
|
});
|
|
});
|
|
}
|
|
|
|
function addPageShowListener(func) {
|
|
gBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() {
|
|
gBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false);
|
|
func();
|
|
});
|
|
}
|