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