Backed out 4 changesets (bug 1563607) for debugger failures on a CLOSED TREE

Backed out changeset c8f4de2596bc (bug 1563607)
Backed out changeset 1dc694b39efa (bug 1563607)
Backed out changeset cec07747fb2a (bug 1563607)
Backed out changeset a0d9b36ac4fe (bug 1563607)
This commit is contained in:
Coroiu Cristina 2019-11-06 20:20:36 +02:00
parent 46068a8d05
commit b78c37e290
14 changed files with 19 additions and 202 deletions

View File

@ -78,8 +78,7 @@ export function connect(
* @static
*/
export function navigated() {
return async function({ dispatch, panel }: ThunkArgs) {
await dispatch(updateThreads());
return async function({ panel }: ThunkArgs) {
panel.emit("reloaded");
};
}

View File

@ -8,14 +8,8 @@ import { differenceBy } from "lodash";
import type { Action, ThunkArgs } from "./types";
import type { ThreadType } from "../types";
import { removeSourceActors } from "./source-actors";
import { newGeneratedSources } from "./sources";
import {
getContext,
getAllThreads,
getThreads,
getSourceActorsForThread,
} from "../selectors";
import { getContext, getThreads, getSourceActorsForThread } from "../selectors";
export function updateThreads(type: ?ThreadType) {
return async function({ dispatch, getState, client }: ThunkArgs) {
@ -42,27 +36,6 @@ export function updateThreads(type: ?ThreadType) {
}
if (addedThreads.length > 0) {
dispatch(({ type: "INSERT_THREADS", cx, threads: addedThreads }: Action));
// Fetch the sources and install breakpoints on any new workers.
// NOTE: This runs in the background and fails quietly because it is
// pretty easy for sources to throw during the fetch if their thread
// shuts down, which would cause test failures.
for (const thread of addedThreads) {
client
.fetchThreadSources(thread.actor)
.then(sources => dispatch(newGeneratedSources(sources)))
.catch(e => console.error(e));
}
}
};
}
export function ensureHasThread(thread: string) {
return async function({ dispatch, getState, client }: ThunkArgs) {
const currentThreads = getAllThreads(getState());
if (!currentThreads.some(t => t.actor == thread)) {
await dispatch(updateThreads("worker"));
await dispatch(updateThreads("contentProcess"));
}
};
}

View File

@ -315,12 +315,10 @@ function autocomplete(
}
function navigate(url: string): Promise<*> {
targets = { worker: {}, contentProcess: {} };
return currentTarget.navigateTo({ url });
}
function reload(): Promise<*> {
targets = { worker: {}, contentProcess: {} };
return currentTarget.reload();
}
@ -449,12 +447,6 @@ async function fetchSources(): Promise<Array<GeneratedSourceData>> {
return sources;
}
async function fetchThreadSources(
thread: string
): Promise<Array<GeneratedSourceData>> {
return getSources(lookupThreadFront(thread));
}
// Check if any of the targets were paused before we opened
// the debugger. If one is paused. Fake a `pause` RDP event
// by directly calling the client event listener.
@ -491,6 +483,8 @@ async function updateThreads(type: ThreadType) {
observeAsmJS: true,
};
const oldActors = Object.keys(targets[type]);
await updateTargets(type, {
currentTarget,
debuggerClient,
@ -498,6 +492,17 @@ async function updateThreads(type: ThreadType) {
options,
});
// Fetch the sources and install breakpoints on any new workers.
// NOTE: This runs in the background and fails quitely because it is
// pretty easy for sources to throw during the fetch if their thread
// shuts down, which would cause test failures.
for (const entry of Object.entries(targets[type])) {
const [actor, { threadFront }] = (entry: any);
if (!oldActors.includes(actor)) {
getSources(threadFront).catch(e => console.error(e));
}
}
return Object.entries(targets[type]).map(([actor, target]) =>
createThread((actor: any), (target: any))
);
@ -591,7 +596,6 @@ const clientCommands = {
pauseOnExceptions,
toggleEventLogging,
fetchSources,
fetchThreadSources,
checkIfAlreadyPaused,
registerSourceActor,
fetchThreads,

View File

@ -16,10 +16,6 @@ import type {
import { createPause, prepareSourcePayload } from "./create";
import sourceQueue from "../../utils/source-queue";
import { recordEvent } from "../../utils/telemetry";
import { features } from "../../utils/prefs";
const {
WorkersListener,
} = require("devtools/client/shared/workers-listener.js");
const CALL_STACK_PAGE_SIZE = 1000;
@ -49,21 +45,9 @@ function setupEvents(dependencies: Dependencies) {
debuggerClient.mainRoot.on("processListChanged", () =>
threadListChanged("contentProcess")
);
// If we are attaching to service workers we need to listen to worker changes
// everywhere in the browser.
if (features.windowlessServiceWorkers) {
const workersListener = new WorkersListener(debuggerClient.mainRoot);
workersListener.addListener(() => threadListChanged("worker"));
}
}
async function paused(threadFront: ThreadFront, packet: PausedPacket) {
// When reloading we might get pauses from threads before they have been
// added to the store. Ensure the pause won't be processed until we've
// finished adding the thread.
await actions.ensureHasThread(threadFront.actor);
// If paused by an explicit interrupt, which are generated by the
// slow script dialog and internal events such as setting
// breakpoints, ignore the event.

View File

@ -5,8 +5,7 @@
// @flow
import { addThreadEventListeners } from "./events";
import { prefs, features } from "../../utils/prefs";
import { sameOrigin } from "../../utils/url";
import { prefs } from "../../utils/prefs";
import type { DebuggerClient, Target } from "./types";
import type { ThreadType } from "../../types";
@ -65,25 +64,12 @@ async function attachTargets(type, targetLists, args) {
}
export async function updateWorkerTargets(type: ThreadType, args: Args) {
const { currentTarget, debuggerClient } = args;
const { currentTarget } = args;
if (!currentTarget.isBrowsingContext || currentTarget.isContentProcess) {
return;
}
const { workers } = await currentTarget.listWorkers();
if (features.windowlessServiceWorkers && currentTarget.url) {
const { service } = await debuggerClient.mainRoot.listAllWorkers();
for (const { active, id, url } of service) {
// Attach to any service workers that are same-origin with our target.
// For now, ignore service workers associated with cross-origin iframes.
if (active && sameOrigin(url, currentTarget.url)) {
const workerTarget = await debuggerClient.mainRoot.getWorker(id);
workers.push(workerTarget);
}
}
}
await attachTargets(type, workers, args);
}

View File

@ -143,7 +143,6 @@ export const features = new PrefsHelper("devtools.debugger.features", {
showOverlay: ["Bool", "overlay"],
inlinePreview: ["Bool", "inline-preview"],
watchpoints: ["Bool", "watchpoints"],
windowlessServiceWorkers: ["Bool", "windowless-service-workers"],
});
export const asyncStore = asyncStoreHelper("debugger", {

View File

@ -37,7 +37,3 @@ export const parse = memoize(function parse(url: string): any {
return defaultUrl;
}
});
export function sameOrigin(firstUrl, secondUrl) {
return parse(firstUrl).origin == parse(secondUrl).origin;
}

View File

@ -159,7 +159,6 @@ skip-if = os == "win"
[browser_dbg-windowless-workers.js]
[browser_dbg-windowless-workers-early-breakpoint.js]
[browser_dbg-worker-exception.js]
[browser_dbg-windowless-service-workers.js]
[browser_dbg-worker-scopes.js]
skip-if = (os == 'linux' && debug) || (os == 'linux' && asan) || ccov #Bug 1456013, Bug 1559547
[browser_dbg-event-handler.js]

View File

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
PromiseTestUtils.whitelistRejectionsGlobally(/Connection closed/);
// Test that sources appear in the debugger when navigating using the BFCache.
add_task(async function() {
const dbg = await initDebugger("doc-bfcache1.html");

View File

@ -1,68 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Test that we can detect a new service worker and hit breakpoints that we've
// set in it.
add_task(async function() {
await pushPref("devtools.debugger.features.windowless-service-workers", true);
await pushPref("devtools.debugger.workers-visible", true);
await pushPref("dom.serviceWorkers.enabled", true);
await pushPref("dom.serviceWorkers.testing.enabled", true);
let dbg = await initDebugger("doc-service-workers.html");
invokeInTab("registerWorker");
await waitForSource(dbg, "service-worker.js");
const workerSource = findSource(dbg, "service-worker.js");
await addBreakpoint(dbg, "service-worker.js", 14);
invokeInTab("fetchFromWorker");
await waitForPaused(dbg);
assertPausedAtSourceAndLine(dbg, workerSource.id, 14);
await dbg.actions.removeAllBreakpoints(getContext(dbg));
await resume(dbg);
// Leave the worker registration in place for the next task.
// Set startup breakpoint for the next test.
//await addBreakpoint(dbg, "service-worker.js", 6);
});
async function checkWorkerThreads(dbg, count) {
await waitUntil(() => dbg.selectors.getThreads().length == count);
ok(true, `Have ${count} threads`);
}
// Test that service workers remain after reloading.
add_task(async function() {
const toolbox = await openNewTabAndToolbox(EXAMPLE_URL + "doc-service-workers.html", "jsdebugger");
const dbg = createDebuggerContext(toolbox);
await checkWorkerThreads(dbg, 1);
await reload(dbg);
await waitForSource(dbg, "service-worker.js");
const workerSource = findSource(dbg, "service-worker.js");
await addBreakpoint(dbg, "service-worker.js", 14);
invokeInTab("fetchFromWorker");
await waitForPaused(dbg);
assertPausedAtSourceAndLine(dbg, workerSource.id, 14);
await checkWorkerThreads(dbg, 1);
await resume(dbg);
invokeInTab("unregisterWorker");
await dbg.actions.removeAllBreakpoints(getContext(dbg));
await checkWorkerThreads(dbg, 0);
});

View File

@ -1,32 +0,0 @@
<script>
async function registerWorker() {
const sw = navigator.serviceWorker;
const swr = await sw.register("service-worker.js", { scope: "" });
dump(`Registered, scope is: ${swr.scope}\n`);
await new Promise(resolve => {
const worker = swr.installing || swr.waiting || swr.active;
if (worker.state === 'activated') {
return resolve();
}
worker.addEventListener('statechange', () => {
if (worker.state === 'activated') {
return resolve();
}
});
});
}
async function unregisterWorker() {
const sw = navigator.serviceWorker;
const swr = await sw.register("service-worker.js", { scope: "" });
return swr.unregister();
}
async function fetchFromWorker() {
const response = await fetch("whatever");
const text = await response.text();
console.log(`Response ${text}`);
}
</script>

View File

@ -1,20 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
dump("Starting\n");
self.addEventListener("activate", event => {
dump("Activate\n");
event.waitUntil(self.clients.claim());
});
self.addEventListener("fetch", event => {
const url = event.request.url;
dump(`Fetch: ${url}\n`);
if (url.includes("whatever")) {
const response = new Response("Service worker response", { statusText: "OK" });
event.respondWith(response);
}
});

View File

@ -85,4 +85,3 @@ pref("devtools.debugger.features.dom-mutation-breakpoints", true);
pref("devtools.debugger.features.log-points", true);
pref("devtools.debugger.features.overlay", true);
pref("devtools.debugger.features.inline-preview", true);
pref("devtools.debugger.features.windowless-service-workers", false);

View File

@ -124,7 +124,7 @@ ServiceWorkerPrivate::~ServiceWorkerPrivate() {
namespace {
class CheckScriptEvaluationWithCallback final : public WorkerDebuggeeRunnable {
class CheckScriptEvaluationWithCallback final : public WorkerRunnable {
nsMainThreadPtrHandle<ServiceWorkerPrivate> mServiceWorkerPrivate;
nsMainThreadPtrHandle<KeepAliveToken> mKeepAliveToken;
@ -142,7 +142,7 @@ class CheckScriptEvaluationWithCallback final : public WorkerDebuggeeRunnable {
ServiceWorkerPrivate* aServiceWorkerPrivate,
KeepAliveToken* aKeepAliveToken,
LifeCycleEventCallback* aScriptEvaluationCallback)
: WorkerDebuggeeRunnable(aWorkerPrivate, WorkerThreadModifyBusyCount),
: WorkerRunnable(aWorkerPrivate),
mServiceWorkerPrivate(new nsMainThreadPtrHolder<ServiceWorkerPrivate>(
"CheckScriptEvaluationWithCallback::mServiceWorkerPrivate",
aServiceWorkerPrivate)),