summaryrefslogtreecommitdiffstats
path: root/devtools/client/framework/test/browser_target_events.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/framework/test/browser_target_events.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/framework/test/browser_target_events.js')
-rw-r--r--devtools/client/framework/test/browser_target_events.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/devtools/client/framework/test/browser_target_events.js b/devtools/client/framework/test/browser_target_events.js
new file mode 100644
index 000000000..d0054a484
--- /dev/null
+++ b/devtools/client/framework/test/browser_target_events.js
@@ -0,0 +1,56 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+var target;
+
+function test()
+{
+ waitForExplicitFinish();
+
+ gBrowser.selectedTab = gBrowser.addTab();
+ BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(onLoad);
+}
+
+function onLoad() {
+ target = TargetFactory.forTab(gBrowser.selectedTab);
+
+ is(target.tab, gBrowser.selectedTab, "Target linked to the right tab.");
+
+ target.once("hidden", onHidden);
+ gBrowser.selectedTab = gBrowser.addTab();
+}
+
+function onHidden() {
+ ok(true, "Hidden event received");
+ target.once("visible", onVisible);
+ gBrowser.removeCurrentTab();
+}
+
+function onVisible() {
+ ok(true, "Visible event received");
+ target.once("will-navigate", onWillNavigate);
+ let mm = getFrameScript();
+ mm.sendAsyncMessage("devtools:test:navigate", { location: "data:text/html,<meta charset='utf8'/>test navigation" });
+}
+
+function onWillNavigate(event, request) {
+ ok(true, "will-navigate event received");
+ // Wait for navigation handling to complete before removing the tab, in order
+ // to avoid triggering assertions.
+ target.once("navigate", executeSoon.bind(null, onNavigate));
+}
+
+function onNavigate() {
+ ok(true, "navigate event received");
+ target.once("close", onClose);
+ gBrowser.removeCurrentTab();
+}
+
+function onClose() {
+ ok(true, "close event received");
+
+ target = null;
+ finish();
+}