mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-28 04:39:07 -10:00
There is 4 patterns here: * Tests using attachThreadActorForUrl like event-listeners ones. I augmented this helper method to call TargetFactory. * Tests using attachTargetActorForUrl like debugger-statement, dbg-navigation and target-scoped-actor. Uses TargetFactory directly. * Tests using connectDebuggerClient like navigateEvents and spaw_actor_in_parent. Uses TargetFactory directly. * All the others, where creating DebuggerClient on their own, and calling listTabs+attachTarget. They now use TargetFactory directly. A note about webconsole-helpers, only consoleClient attribute was used from tests using this helper. Also, in various tests I remove the call to client.destroy, that's because shared-head will close all the tabs/toolboxes and it should lead to target/client destruction. Finally, debugger-statement now request the thread actor via the client instead of manual request, it should help the refactoring to a front! MozReview-Commit-ID: 2ah4UmSjuoi Depends on D12730 Differential Revision: https://phabricator.services.mozilla.com/D12731
59 lines
1.6 KiB
JavaScript
59 lines
1.6 KiB
JavaScript
/* -*- 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/ */
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Check tab attach/navigation.
|
|
*/
|
|
|
|
const TAB1_URL = EXAMPLE_URL + "doc_empty-tab-01.html";
|
|
const TAB2_FILE = "doc_empty-tab-02.html";
|
|
const TAB2_URL = EXAMPLE_URL + TAB2_FILE;
|
|
|
|
add_task(async () => {
|
|
const tab = await addTab(TAB1_URL);
|
|
const target = await TargetFactory.forTab(tab);
|
|
await target.attach();
|
|
const targetFront = target.activeTab;
|
|
|
|
await testNavigate(targetFront);
|
|
await testDetach(target);
|
|
});
|
|
|
|
function testNavigate(targetFront) {
|
|
const outstanding = [promise.defer(), promise.defer()];
|
|
|
|
targetFront.on("tabNavigated", function onTabNavigated(packet) {
|
|
is(packet.url.split("/").pop(), TAB2_FILE,
|
|
"Got a tab navigation notification.");
|
|
|
|
info(JSON.stringify(packet));
|
|
|
|
if (packet.state == "start") {
|
|
ok(true, "Tab started to navigate.");
|
|
outstanding[0].resolve();
|
|
} else {
|
|
ok(true, "Tab finished navigating.");
|
|
targetFront.off("tabNavigated", onTabNavigated);
|
|
outstanding[1].resolve();
|
|
}
|
|
});
|
|
|
|
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TAB2_URL);
|
|
return promise.all(outstanding.map(e => e.promise));
|
|
}
|
|
|
|
async function testDetach(target) {
|
|
// We can't listen for tabDetached at it is received by Target first
|
|
// and target is destroyed
|
|
const onDetached = target.once("close");
|
|
|
|
removeTab(gBrowser.selectedTab);
|
|
|
|
await onDetached;
|
|
ok(true, "Got a tab detach notification.");
|
|
}
|