Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | const middleMousePastePref = "middlemouse.contentLoadURL"; |
michael@0 | 5 | const autoScrollPref = "general.autoScroll"; |
michael@0 | 6 | function test() { |
michael@0 | 7 | waitForExplicitFinish(); |
michael@0 | 8 | |
michael@0 | 9 | Services.prefs.setBoolPref(middleMousePastePref, true); |
michael@0 | 10 | Services.prefs.setBoolPref(autoScrollPref, false); |
michael@0 | 11 | let tab = gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 12 | |
michael@0 | 13 | registerCleanupFunction(function () { |
michael@0 | 14 | Services.prefs.clearUserPref(middleMousePastePref); |
michael@0 | 15 | Services.prefs.clearUserPref(autoScrollPref); |
michael@0 | 16 | gBrowser.removeTab(tab); |
michael@0 | 17 | }); |
michael@0 | 18 | |
michael@0 | 19 | addPageShowListener(function () { |
michael@0 | 20 | let pagePrincipal = gBrowser.contentPrincipal; |
michael@0 | 21 | |
michael@0 | 22 | // copy javascript URI to the clipboard |
michael@0 | 23 | let url = "javascript:1+1"; |
michael@0 | 24 | waitForClipboard(url, |
michael@0 | 25 | function() { |
michael@0 | 26 | Components.classes["@mozilla.org/widget/clipboardhelper;1"] |
michael@0 | 27 | .getService(Components.interfaces.nsIClipboardHelper) |
michael@0 | 28 | .copyString(url, document); |
michael@0 | 29 | }, |
michael@0 | 30 | function () { |
michael@0 | 31 | // Middle click on the content area |
michael@0 | 32 | info("Middle clicking"); |
michael@0 | 33 | EventUtils.sendMouseEvent({type: "click", button: 1}, gBrowser); |
michael@0 | 34 | }, |
michael@0 | 35 | function() { |
michael@0 | 36 | ok(false, "Failed to copy URL to the clipboard"); |
michael@0 | 37 | finish(); |
michael@0 | 38 | } |
michael@0 | 39 | ); |
michael@0 | 40 | |
michael@0 | 41 | addPageShowListener(function () { |
michael@0 | 42 | is(gBrowser.currentURI.spec, url, "url loaded by middle click"); |
michael@0 | 43 | ok(!gBrowser.contentPrincipal.equals(pagePrincipal), |
michael@0 | 44 | "middle click load of " + url + " should produce a page with a different principal"); |
michael@0 | 45 | finish(); |
michael@0 | 46 | }); |
michael@0 | 47 | }); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function addPageShowListener(func) { |
michael@0 | 51 | gBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() { |
michael@0 | 52 | gBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false); |
michael@0 | 53 | func(); |
michael@0 | 54 | }); |
michael@0 | 55 | } |