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 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 2 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 4 | |
michael@0 | 5 | var target; |
michael@0 | 6 | |
michael@0 | 7 | function test() |
michael@0 | 8 | { |
michael@0 | 9 | waitForExplicitFinish(); |
michael@0 | 10 | |
michael@0 | 11 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 12 | gBrowser.selectedBrowser.addEventListener("load", onLoad, true); |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | function onLoad(evt) { |
michael@0 | 16 | gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true); |
michael@0 | 17 | |
michael@0 | 18 | target = TargetFactory.forTab(gBrowser.selectedTab); |
michael@0 | 19 | |
michael@0 | 20 | is(target.tab, gBrowser.selectedTab, "Target linked to the right tab."); |
michael@0 | 21 | |
michael@0 | 22 | target.once("hidden", onHidden); |
michael@0 | 23 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | function onHidden() { |
michael@0 | 27 | ok(true, "Hidden event received"); |
michael@0 | 28 | target.once("visible", onVisible); |
michael@0 | 29 | gBrowser.removeCurrentTab(); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function onVisible() { |
michael@0 | 33 | ok(true, "Visible event received"); |
michael@0 | 34 | target.once("will-navigate", onWillNavigate); |
michael@0 | 35 | gBrowser.contentWindow.location = "data:text/html,test navigation"; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function onWillNavigate(event, request) { |
michael@0 | 39 | ok(true, "will-navigate event received"); |
michael@0 | 40 | // Wait for navigation handling to complete before removing the tab, in order |
michael@0 | 41 | // to avoid triggering assertions. |
michael@0 | 42 | target.once("navigate", executeSoon.bind(null, onNavigate)); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function onNavigate() { |
michael@0 | 46 | ok(true, "navigate event received"); |
michael@0 | 47 | target.once("close", onClose); |
michael@0 | 48 | gBrowser.removeCurrentTab(); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | function onClose() { |
michael@0 | 52 | ok(true, "close event received"); |
michael@0 | 53 | |
michael@0 | 54 | target = null; |
michael@0 | 55 | finish(); |
michael@0 | 56 | } |