Bug 1527122 - [release 125] [Sources] RelativeSources attributes were not updated (#7910). r=dwalsh
authorderek-li <33161837+derek-li@users.noreply.github.com>
Mon, 11 Feb 2019 17:00:06 -0800
changeset 458681 14277097be36
parent 458680 3bcdb1bf19fc
child 458682 44491c6093d4
push id35544
push userccoroiu@mozilla.com
push dateTue, 12 Feb 2019 16:29:08 +0000
treeherdermozilla-central@c849fb69e2e7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdwalsh
bugs1527122
milestone67.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 1527122 - [release 125] [Sources] RelativeSources attributes were not updated (#7910). r=dwalsh
devtools/client/debugger/new/src/actions/sources/tests/blackbox.spec.js
devtools/client/debugger/new/src/reducers/sources.js
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/src/actions/sources/tests/blackbox.spec.js
@@ -0,0 +1,32 @@
+/* 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/>. */
+
+// @flow
+
+import {
+  actions,
+  selectors,
+  createStore,
+  makeSource
+} from "../../../utils/test-head";
+
+describe("blackbox", () => {
+  it("should blackbox a source", async () => {
+    const store = createStore({ blackBox: async () => true });
+    const { dispatch, getState } = store;
+
+    const foo1CSR = makeSource("foo1");
+    await dispatch(actions.newSource(foo1CSR));
+    await dispatch(actions.toggleBlackBox(foo1CSR.source));
+
+    const fooSource = selectors.getSource(getState(), "foo1");
+    const relativeSources = selectors.getRelativeSourcesForThread(
+      getState(),
+      foo1CSR.sourceActor.thread
+    );
+
+    expect(relativeSources[fooSource.id].isBlackBoxed).toEqual(true);
+    expect(fooSource.isBlackBoxed).toEqual(true);
+  });
+});
--- a/devtools/client/debugger/new/src/reducers/sources.js
+++ b/devtools/client/debugger/new/src/reducers/sources.js
@@ -271,20 +271,34 @@ function updateSource(state: SourcesStat
 
   const existingSource = state.sources[source.id];
   const updatedSource = existingSource
     ? { ...existingSource, ...source }
     : createSource(source);
 
   state.sources[source.id] = updatedSource;
 
+  updateExistingRelativeSource(state, source);
   updateSourceUrl(state, source);
   updateOriginalSources(state, source);
 }
 
+function updateExistingRelativeSource(state: SourcesState, source: Object) {
+  const relativeSources = { ...state.relativeSources };
+
+  for (const thread in relativeSources) {
+    if (relativeSources[thread][source.id]) {
+      relativeSources[thread] = { ...relativeSources[thread] };
+      const existingRelativeSource = relativeSources[thread][source.id];
+      const updatedRelativeSource = { ...existingRelativeSource, ...source };
+      state.relativeSources[thread][source.id] = updatedRelativeSource;
+    }
+  }
+}
+
 function updateRelativeSource(
   state: SourcesState,
   source: Object,
   sourceActor: SourceActor
 ) {
   const root = state.projectDirectoryRoot;
 
   if (!underRoot(source, root)) {