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 URL = "about:robots"; |
michael@0 | 5 | |
michael@0 | 6 | function test() { |
michael@0 | 7 | let win; |
michael@0 | 8 | |
michael@0 | 9 | let listener = { |
michael@0 | 10 | onLocationChange: (webProgress, request, uri, flags) => { |
michael@0 | 11 | ok(webProgress.isTopLevel, "Received onLocationChange from top frame"); |
michael@0 | 12 | is(uri.spec, URL, "Received onLocationChange for correct URL"); |
michael@0 | 13 | finish(); |
michael@0 | 14 | } |
michael@0 | 15 | }; |
michael@0 | 16 | |
michael@0 | 17 | waitForExplicitFinish(); |
michael@0 | 18 | |
michael@0 | 19 | // Remove the listener and window when we're done. |
michael@0 | 20 | registerCleanupFunction(() => { |
michael@0 | 21 | win.gBrowser.removeProgressListener(listener); |
michael@0 | 22 | win.close(); |
michael@0 | 23 | }); |
michael@0 | 24 | |
michael@0 | 25 | // Wait for the newly opened window. |
michael@0 | 26 | whenNewWindowOpened(w => win = w); |
michael@0 | 27 | |
michael@0 | 28 | // Open a link in a new window. |
michael@0 | 29 | openLinkIn(URL, "window", {}); |
michael@0 | 30 | |
michael@0 | 31 | // On the next tick, but before the window has finished loading, access the |
michael@0 | 32 | // window's gBrowser property to force the tabbrowser constructor early. |
michael@0 | 33 | (function tryAddProgressListener() { |
michael@0 | 34 | executeSoon(() => { |
michael@0 | 35 | try { |
michael@0 | 36 | win.gBrowser.addProgressListener(listener); |
michael@0 | 37 | } catch (e) { |
michael@0 | 38 | // win.gBrowser wasn't ready, yet. Try again in a tick. |
michael@0 | 39 | tryAddProgressListener(); |
michael@0 | 40 | } |
michael@0 | 41 | }); |
michael@0 | 42 | })(); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function whenNewWindowOpened(cb) { |
michael@0 | 46 | Services.obs.addObserver(function obs(win) { |
michael@0 | 47 | Services.obs.removeObserver(obs, "domwindowopened"); |
michael@0 | 48 | cb(win); |
michael@0 | 49 | }, "domwindowopened", false); |
michael@0 | 50 | } |