Bug 1544813: Show sources regardless devtools.chrome.enabled even in case of web extension. r=jdescottes,jlast
☠☠ backed out by 2a832d03ebcc ☠ ☠
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Thu, 16 May 2019 01:14:41 +0000
changeset 532874 ac87e6ddded678765e2643d86a9ce65512ab9f56
parent 532860 4b635d928b2bd42890ffc97c55622072092351e9
child 532875 6a315be5f16ff419f73e35c65d2eb9259e5ebb21
push id11276
push userrgurzau@mozilla.com
push dateMon, 20 May 2019 13:11:24 +0000
treeherdermozilla-beta@847755a7c325 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes, jlast
bugs1544813
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1544813: Show sources regardless devtools.chrome.enabled even in case of web extension. r=jdescottes,jlast Differential Revision: https://phabricator.services.mozilla.com/D31223
devtools/client/debugger/src/actions/navigation.js
devtools/client/debugger/src/client/firefox.js
devtools/client/debugger/src/reducers/debuggee.js
devtools/client/debugger/src/reducers/sources.js
devtools/client/debugger/src/reducers/tests/sources.spec.js
--- a/devtools/client/debugger/src/actions/navigation.js
+++ b/devtools/client/debugger/src/actions/navigation.js
@@ -43,24 +43,30 @@ export function willNavigate(event: Obje
 
     dispatch({
       type: "NAVIGATE",
       mainThread: { ...thread, url: event.url }
     });
   };
 }
 
-export function connect(url: string, actor: string, canRewind: boolean) {
+export function connect(
+  url: string,
+  actor: string,
+  canRewind: boolean,
+  isWebExtension: boolean
+) {
   return async function({ dispatch }: ThunkArgs) {
     await dispatch(updateWorkers());
     dispatch(
       ({
         type: "CONNECT",
         mainThread: { url, actor, type: -1, name: "" },
-        canRewind
+        canRewind,
+        isWebExtension
       }: Action)
     );
   };
 }
 
 /**
  * @memberof actions/navigation
  * @static
--- a/devtools/client/debugger/src/client/firefox.js
+++ b/devtools/client/debugger/src/client/firefox.js
@@ -53,17 +53,18 @@ export async function onConnect(connecti
   // the debugger (if it's paused already, or if loading the page from
   // bfcache) so explicity fire `newSource` events for all returned
   // sources.
   const sourceInfo = await clientCommands.fetchSources();
   const traits = tabTarget.traits;
   await actions.connect(
     tabTarget.url,
     threadClient.actor,
-    traits && traits.canRewind
+    traits && traits.canRewind,
+    tabTarget.isWebExtension
   );
   await actions.newGeneratedSources(sourceInfo);
 
   // If the threadClient is already paused, make sure to show a
   // paused state.
   const pausedPacket = threadClient.getLastPausePacket();
   if (pausedPacket) {
     clientEvents.paused(threadClient, "paused", pausedPacket);
--- a/devtools/client/debugger/src/reducers/debuggee.js
+++ b/devtools/client/debugger/src/reducers/debuggee.js
@@ -21,29 +21,31 @@ import type { Action } from "../actions/
 export type DebuggeeState = {
   workers: WorkerList,
   mainThread: MainThread
 };
 
 export function initialDebuggeeState(): DebuggeeState {
   return {
     workers: [],
-    mainThread: { actor: "", url: "", type: -1, name: "" }
+    mainThread: { actor: "", url: "", type: -1, name: "" },
+    isWebExtension: false
   };
 }
 
 export default function debuggee(
   state: DebuggeeState = initialDebuggeeState(),
   action: Action
 ): DebuggeeState {
   switch (action.type) {
     case "CONNECT":
       return {
         ...state,
-        mainThread: { ...action.mainThread, name: L10N.getStr("mainThread") }
+        mainThread: { ...action.mainThread, name: L10N.getStr("mainThread") },
+        isWebExtension: action.isWebExtension
       };
     case "INSERT_WORKERS":
       return insertWorkers(state, action.workers);
     case "REMOVE_WORKERS":
       const { workers } = action;
       return {
         ...state,
         workers: state.workers.filter(w => !workers.includes(w.actor))
--- a/devtools/client/debugger/src/reducers/sources.js
+++ b/devtools/client/debugger/src/reducers/sources.js
@@ -792,44 +792,47 @@ export function getSelectedSourceId(stat
 }
 
 export function getProjectDirectoryRoot(state: OuterState): string {
   return state.sources.projectDirectoryRoot;
 }
 
 const queryAllDisplayedSources: ReduceQuery<
   SourceResource,
-  {| projectDirectoryRoot: string, chromeAndExtensionsEnabled: boolean |},
+  {| projectDirectoryRoot: string,
+     chromeAndExtensionsEnabled: boolean,
+     debuggeeIsWebExtension: boolean |},
   Array<SourceId>
 > = makeReduceQuery(
   makeMapWithArgs(
     (
       resource,
       ident,
-      { projectDirectoryRoot, chromeAndExtensionsEnabled }
+      { projectDirectoryRoot, chromeAndExtensionsEnabled, debuggeeIsWebExtension }
     ) => ({
       id: resource.id,
       displayed:
         underRoot(resource, projectDirectoryRoot) &&
-        (!resource.isExtension || chromeAndExtensionsEnabled)
+        (!resource.isExtension || chromeAndExtensionsEnabled || debuggeeIsWebExtension)
     })
   ),
   items =>
     items.reduce((acc, { id, displayed }) => {
       if (displayed) {
         acc.push(id);
       }
       return acc;
     }, [])
 );
 
 function getAllDisplayedSources(state: OuterState): Array<SourceId> {
   return queryAllDisplayedSources(state.sources.sources, {
     projectDirectoryRoot: state.sources.projectDirectoryRoot,
-    chromeAndExtensionsEnabled: state.sources.chromeAndExtenstionsEnabled
+    chromeAndExtensionsEnabled: state.sources.chromeAndExtenstionsEnabled,
+    debuggeeIsWebExtension: state.debuggee.isWebExtension
   });
 }
 
 type GetDisplayedSourceIDsSelector = (
   OuterState & SourceActorOuterState
 ) => { [ThreadId]: Set<SourceId> };
 const getDisplayedSourceIDs: GetDisplayedSourceIDsSelector = createSelector(
   getThreadsBySource,
--- a/devtools/client/debugger/src/reducers/tests/sources.spec.js
+++ b/devtools/client/debugger/src/reducers/tests/sources.spec.js
@@ -62,63 +62,68 @@ const mockSourceActors: Array<SourceActo
 ]: any);
 
 describe("sources reducer", () => {
   it("should work", () => {
     let state = initialSourcesState();
     state = update(state, {
       type: "ADD_SOURCE",
       cx: mockcx,
+      debuggee: { isWebExtension: false },
       source: makeMockSource()
     });
     expect(getResourceIds(state.sources)).toHaveLength(1);
   });
 });
 
 describe("sources selectors", () => {
   it("should return all extensions when chrome preference enabled", () => {
     prefs.chromeAndExtenstionsEnabled = true;
     let state = initialSourcesState();
     state = {
       sources: update(state, {
         type: "ADD_SOURCES",
         cx: mockcx,
+        debuggee: { isWebExtension: false },
         sources: ((mockedSources: any): Source[])
       }),
       sourceActors: undefined
     };
     const insertAction = {
       type: "INSERT_SOURCE_ACTORS",
       items: mockSourceActors
     };
     state = {
+      debuggee: { isWebExtension: false },
       sources: update(state.sources, insertAction),
       sourceActors: updateSourceActors(state.sourceActors, insertAction)
     };
     const threadSources = getDisplayedSources(state);
     expect(Object.values(threadSources.foo)).toHaveLength(3);
   });
 
   it("should omit all extensions when chrome preference enabled", () => {
     prefs.chromeAndExtenstionsEnabled = false;
     let state = initialSourcesState();
     state = {
       sources: update(state, {
         type: "ADD_SOURCES",
         cx: mockcx,
+        debuggee: { isWebExtension: false },
         sources: ((mockedSources: any): Source[])
       }),
       sourceActors: undefined
     };
 
     const insertAction = {
       type: "INSERT_SOURCE_ACTORS",
       items: mockSourceActors
     };
 
     state = {
+      debuggee: { isWebExtension: false },
       sources: update(state.sources, insertAction),
       sourceActors: updateSourceActors(state.sourceActors, insertAction)
     };
     const threadSources = getDisplayedSources(state);
     expect(Object.values(threadSources.foo)).toHaveLength(1);
   });
 });