Bug 1530415 - Fix recent jest regressions. r=bhackett
authorJason Laster <jlaster@mozilla.com>
Mon, 25 Feb 2019 18:39:17 +0000
changeset 460950 5e240b5794fcf316368e5027b52884a7aec0268c
parent 460949 271d947b5c4b84fbbbaf020655f680e21cd12ced
child 460951 98486a2bc3c60878d4fce5073eacff3bd1df17b1
push id35613
push usernerli@mozilla.com
push dateTue, 26 Feb 2019 03:52:35 +0000
treeherdermozilla-central@faec87a80ed1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1530415
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 1530415 - Fix recent jest regressions. r=bhackett Differential Revision: https://phabricator.services.mozilla.com/D21029
devtools/client/debugger/new/jest-test.config.js
devtools/client/debugger/new/src/actions/breakpoints/tests/__snapshots__/breakpoints.spec.js.snap
devtools/client/debugger/new/src/actions/sources/tests/__snapshots__/prettyPrint.spec.js.snap
devtools/client/debugger/new/src/actions/tests/pending-breakpoints.spec.js
devtools/client/debugger/new/src/client/firefox/create.js
devtools/client/debugger/new/src/components/PrimaryPanes/tests/__snapshots__/PrimaryPanes.spec.js.snap
devtools/client/debugger/new/src/components/PrimaryPanes/tests/__snapshots__/SourcesTree.spec.js.snap
devtools/client/debugger/new/src/reducers/tests/sources.spec.js
devtools/client/debugger/new/src/workers/parser/tests/__snapshots__/pausePoints.spec.js.snap
--- a/devtools/client/debugger/new/jest-test.config.js
+++ b/devtools/client/debugger/new/jest-test.config.js
@@ -12,26 +12,26 @@ module.exports = {
     "/node_modules/",
     "/helpers/",
     "/fixtures/",
     "src/test/mochitest/examples/",
     "<rootDir>/firefox",
     "package.json",
     "<rootDir>/packages"
   ],
-  modulePathIgnorePatterns: ["src/test/mochitest", "firefox"],
+  modulePathIgnorePatterns: ["test/mochitest", "firefox"],
   collectCoverageFrom: [
     "src/**/*.js",
     "!src/**/fixtures/*.js",
     "!src/test/**/*.js",
     "!src/components/stories/**/*.js",
     "!**/*.mock.js",
     "!**/*.spec.js"
   ],
-  transformIgnorePatterns: ["node_modules/(?!devtools-)"],
+  transformIgnorePatterns: ["node_modules/(?!(devtools-|react-aria-))"],
   setupTestFrameworkScriptFile: "<rootDir>/src/test/tests-setup.js",
   setupFiles: ["<rootDir>/src/test/shim.js", "jest-localstorage-mock"],
   snapshotSerializers: [
     "jest-serializer-babel-ast",
     "enzyme-to-json/serializer"
   ],
   moduleNameMapper: {
     "\\.css$": "<rootDir>/src/test/__mocks__/styleMock.js",
--- a/devtools/client/debugger/new/src/actions/breakpoints/tests/__snapshots__/breakpoints.spec.js.snap
+++ b/devtools/client/debugger/new/src/actions/breakpoints/tests/__snapshots__/breakpoints.spec.js.snap
@@ -40,25 +40,18 @@ Array [
       "actors": Array [
         Object {
           "actor": "a-actor",
           "source": "a",
           "thread": "FakeThread",
         },
       ],
       "contentType": "text/javascript",
-      "error": undefined,
       "id": "a",
-      "isBlackBoxed": false,
-      "isExtension": false,
-      "isPrettyPrinted": false,
-      "isWasm": false,
       "loadedState": "loaded",
-      "relativeUrl": "/examples/a",
-      "sourceMapURL": undefined,
       "text": "function a() {
   return a 
 }",
       "url": "http://localhost:8000/examples/a",
     },
   },
 ]
 `;
@@ -140,25 +133,18 @@ Array [
       "actors": Array [
         Object {
           "actor": "a-actor",
           "source": "a",
           "thread": "FakeThread",
         },
       ],
       "contentType": "text/javascript",
-      "error": undefined,
       "id": "a",
-      "isBlackBoxed": false,
-      "isExtension": false,
-      "isPrettyPrinted": false,
-      "isWasm": false,
       "loadedState": "loaded",
-      "relativeUrl": "/examples/a",
-      "sourceMapURL": undefined,
       "text": "function a() {
   return a 
 }",
       "url": "http://localhost:8000/examples/a",
     },
   },
 ]
 `;
--- a/devtools/client/debugger/new/src/actions/sources/tests/__snapshots__/prettyPrint.spec.js.snap
+++ b/devtools/client/debugger/new/src/actions/sources/tests/__snapshots__/prettyPrint.spec.js.snap
@@ -1,21 +1,19 @@
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
 exports[`sources - pretty print returns a pretty source for a minified file 1`] = `
 Object {
   "actors": Array [],
   "contentType": "text/javascript",
-  "error": undefined,
   "id": "base.js/originalSource-36c718d4bde9a75edb388ff7733efe7f",
   "introductionUrl": null,
   "isBlackBoxed": false,
   "isExtension": false,
   "isPrettyPrinted": true,
   "isWasm": false,
   "loadedState": "loaded",
   "relativeUrl": "http://localhost:8000/examples/base.js:formatted",
-  "sourceMapURL": undefined,
   "text": "undefined
 ",
   "url": "http://localhost:8000/examples/base.js:formatted",
 }
 `;
--- a/devtools/client/debugger/new/src/actions/tests/pending-breakpoints.spec.js
+++ b/devtools/client/debugger/new/src/actions/tests/pending-breakpoints.spec.js
@@ -19,16 +19,17 @@ function loadInitialState(opts = {}) {
   const id = makePendingLocationId(mockedPendingBreakpoint.location);
   asyncStore.pendingBreakpoints = { [id]: mockedPendingBreakpoint };
 
   return { pendingBreakpoints: asyncStore.pendingBreakpoints };
 }
 
 jest.mock("../../utils/prefs", () => ({
   prefs: {
+    clientSourceMapsEnabled: true,
     expressions: []
   },
   asyncStore: {
     pendingBreakpoints: {}
   },
   features: {
     replay: false
   },
@@ -359,14 +360,11 @@ describe("adding sources", () => {
     const source2 = makeOriginalSource("foo.js");
     await dispatch(actions.newSource(makeSource("bar.js")));
     await dispatch(actions.newSource(makeSource("foo.js")));
     await dispatch(actions.newSources([source1, source2]));
     await dispatch(actions.loadSourceText(source1));
     await dispatch(actions.loadSourceText(source2));
 
     await waitForState(store, state => selectors.getBreakpointCount(state) > 0);
-
-    // N.B. this test is kind of broken and creates different breakpoints for
-    // the generated and original bar.js sources.
-    expect(selectors.getBreakpointCount(getState())).toEqual(2);
+    expect(selectors.getBreakpointCount(getState())).toEqual(1);
   });
 });
--- a/devtools/client/debugger/new/src/client/firefox/create.js
+++ b/devtools/client/debugger/new/src/client/firefox/create.js
@@ -1,15 +1,17 @@
 /* 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
 // This module converts Firefox specific types to the generic types
 
+import { isUrlExtension } from "../../utils/source";
+
 import type { Frame, Source, ThreadId } from "../../types";
 import type {
   PausedPacket,
   FramesResponse,
   FramePacket,
   SourcePayload
 } from "./types";
 
@@ -58,16 +60,17 @@ export function createSource(
     url: source.url,
     relativeUrl: source.url,
     isPrettyPrinted: false,
     sourceMapURL: source.sourceMapURL,
     introductionUrl: source.introductionUrl,
     isBlackBoxed: false,
     loadedState: "unloaded",
     isWasm: supportsWasm && source.introductionType === "wasm",
+    isExtension: (source.url && isUrlExtension(source.url)) || false,
     actors: [sourceActor]
   };
   clientCommands.registerSourceActor(sourceActor);
   return createdSource;
 }
 
 export function createPause(
   thread: string,
--- a/devtools/client/debugger/new/src/components/PrimaryPanes/tests/__snapshots__/PrimaryPanes.spec.js.snap
+++ b/devtools/client/debugger/new/src/components/PrimaryPanes/tests/__snapshots__/PrimaryPanes.spec.js.snap
@@ -27,17 +27,19 @@ exports[`PrimaryPanes with custom root r
       Outline
     </Tab>
   </TabList>
   <TabPanels
     activeIndex={0}
     className="source-outline-panel has-root"
     hasFocusableContent={true}
   >
-    <div>
+    <div
+      className="threads-list"
+    >
       <div
         className="sources-clear-root-container"
         key="root"
       >
         <button
           className="sources-clear-root"
           onClick={[Function]}
           title="Remove directory root"
@@ -91,17 +93,19 @@ exports[`PrimaryPanes with custom root r
       Outline
     </Tab>
   </TabList>
   <TabPanels
     activeIndex={0}
     className="source-outline-panel has-root"
     hasFocusableContent={true}
   >
-    <div>
+    <div
+      className="threads-list"
+    >
       <div
         className="sources-clear-root-container"
         key="root"
       >
         <button
           className="sources-clear-root"
           onClick={[Function]}
           title="Remove directory root"
--- a/devtools/client/debugger/new/src/components/PrimaryPanes/tests/__snapshots__/SourcesTree.spec.js.snap
+++ b/devtools/client/debugger/new/src/components/PrimaryPanes/tests/__snapshots__/SourcesTree.spec.js.snap
@@ -1,16 +1,28 @@
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
 exports[`SourcesTree After changing expanded nodes Shows the tree with four.js, five.js and six.js expanded 1`] = `
 <div
-  className="sources-pane"
+  className="sources-pane thread"
   key="pane"
 >
   <div
+    className="node thread-header"
+  >
+    <AccessibleImage
+      className="file"
+    />
+    <span
+      className="label"
+    >
+      Main Thread
+    </span>
+  </div>
+  <div
     className="sources-list"
     key="tree"
     onKeyDown={[Function]}
   >
     <ManagedTree
       autoExpandAll={false}
       autoExpandDepth={0}
       expanded={
@@ -33,20 +45,32 @@ exports[`SourcesTree After changing expa
       renderItem={[Function]}
     />
   </div>
 </div>
 `;
 
 exports[`SourcesTree Should show the tree with nothing expanded 1`] = `
 <div
-  className="sources-pane"
+  className="sources-pane thread"
   key="pane"
 >
   <div
+    className="node thread-header"
+  >
+    <AccessibleImage
+      className="file"
+    />
+    <span
+      className="label"
+    >
+      Main Thread
+    </span>
+  </div>
+  <div
     className="sources-list"
     key="tree"
     onKeyDown={[Function]}
   >
     <ManagedTree
       autoExpandAll={false}
       autoExpandDepth={1}
       getChildren={[Function]}
@@ -62,20 +86,32 @@ exports[`SourcesTree Should show the tre
       renderItem={[Function]}
     />
   </div>
 </div>
 `;
 
 exports[`SourcesTree When loading initial source Shows the tree with one.js, two.js and three.js expanded 1`] = `
 <div
-  className="sources-pane"
+  className="sources-pane thread"
   key="pane"
 >
   <div
+    className="node thread-header"
+  >
+    <AccessibleImage
+      className="file"
+    />
+    <span
+      className="label"
+    >
+      Main Thread
+    </span>
+  </div>
+  <div
     className="sources-list"
     key="tree"
     onKeyDown={[Function]}
   >
     <ManagedTree
       autoExpandAll={false}
       autoExpandDepth={0}
       expanded={
@@ -98,20 +134,32 @@ exports[`SourcesTree When loading initia
       renderItem={[Function]}
     />
   </div>
 </div>
 `;
 
 exports[`SourcesTree on receiving new props updates highlighted items updates highlightItems if selectedSource changes 1`] = `
 <div
-  className="sources-pane"
+  className="sources-pane thread"
   key="pane"
 >
   <div
+    className="node thread-header"
+  >
+    <AccessibleImage
+      className="file"
+    />
+    <span
+      className="label"
+    >
+      Main Thread
+    </span>
+  </div>
+  <div
     className="sources-list"
     key="tree"
     onKeyDown={[Function]}
   >
     <ManagedTree
       autoExpandAll={false}
       autoExpandDepth={1}
       getChildren={[Function]}
--- a/devtools/client/debugger/new/src/reducers/tests/sources.spec.js
+++ b/devtools/client/debugger/new/src/reducers/tests/sources.spec.js
@@ -6,39 +6,47 @@
 declare var describe: (name: string, func: () => void) => void;
 declare var it: (desc: string, func: () => void) => void;
 declare var expect: (value: any) => any;
 
 import update, { initialSourcesState, getDisplayedSources } from "../sources";
 import { foobar } from "../../test/fixtures";
 import type { Source } from "../../types";
 import { prefs } from "../../utils/prefs";
+import { makeMockSource } from "../../utils/test-mockup";
+
+
 
 const fakeSources = foobar.sources.sources;
 
 const extensionSource = {
+  ...makeMockSource(),
   id: "extensionId",
   url: "http://example.com/script.js",
   actors: [{ actor: "extensionId-actor", source: "extensionId", thread: "foo" }]
-};
+}
 
 const firefoxExtensionSource = {
+  ...makeMockSource(),
   id: "firefoxExtension",
   url: "moz-extension://id/js/content.js",
+  isExtension: true,
   actors: [
     {
       actor: "firefoxExtension-actor",
       source: "firefoxExtension",
       thread: "foo"
     }
   ]
 };
 
 const chromeExtensionSource = {
+  ...makeMockSource(),
   id: "chromeExtension",
+  isExtension: true,
   url: "chrome-extension://id/js/content.js",
   actors: [
     { actor: "chromeExtension-actor", source: "chromeExtension", thread: "foo" }
   ]
 };
 
 const mockedSources = [
   extensionSource,
@@ -46,18 +54,17 @@ const mockedSources = [
   chromeExtensionSource
 ];
 
 describe("sources reducer", () => {
   it("should work", () => {
     let state = initialSourcesState();
     state = update(state, {
       type: "ADD_SOURCE",
-      // coercing to a Source for the purpose of this test
-      source: ((fakeSources.fooSourceActor: any): Source)
+      source: makeMockSource()
     });
     expect(Object.keys(state.sources)).toHaveLength(1);
   });
 });
 
 describe("sources selectors", () => {
   it("should return all extensions when chrome preference enabled", () => {
     prefs.chromeAndExtenstionsEnabled = true;
deleted file mode 100644
--- a/devtools/client/debugger/new/src/workers/parser/tests/__snapshots__/pausePoints.spec.js.snap
+++ /dev/null
@@ -1,251 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Parser.pausePoints calls 1`] = `
-"/*bs*/foo(/**/1, /**/'2', /*bs*/bar())
-
-/*bs*/foo()
-  ./*bs*/bar()
-  ./*bs*/bazz()
-
-/*bs*/console./*bs*/log(/**/'yo')
-
-/*bs*/foo(
-  /**/1,
-  /*bs*/bar()
-)
-
-var /*bs*/a = 3;
-
-// set a step point at the first call expression in step expressions
-var /*bs*/x = { /**/a: /*bs*/a(), /**/b: /*b*/b(), /**/c: /*b*/c() };
-var /*bs*/b = /**/[ /*bs*/foo() ];
-/**/[ /*bs*/a(), /*b*/b(), /*b*/c() ];
-(/**/1, /*bs*/a(), /*b*/b());
-/*bs*/x(/**/1, /*bs*/a(), /*b*/b());
-"
-`;
-
-exports[`Parser.pausePoints control-flow 1`] = `
-"
-/*bs*/if (/*bs*/x) /**/{
-  /*bs*/foo();
-}
-else /*bs*/if (/*bs*/y) /**/{
-  /*bs*/foo();
-}
-else /**/{
-  /*bs*/foo();
-}
-
-/*bs*/for (var /*bs*/i=0; /*bs*/i< 5; i++ ) /**/{
-  /*bs*/foo();
-}
-
-/*bs*/while (/*bs*/x) /**/{
-  /*bs*/foo();
-}
-
-/*bs*/switch (/*bs*/c) {
-  /*bs*/case /*bs*/a:
-    /*bs*/console./*bs*/log(/**/'hi')
-}
-
-var /*bs*/a = 3;
-
-/*bs*/for (const /*bs*/val of /**/[/**/1, /**/2]) /**/{
-  /*bs*/console./*bs*/log(/**/\\"pause again\\", /**/val);
-}
-
-/*bs*/for (const /*bs*/val of vals) /**/{
-  /*bs*/console./*bs*/log(/**/\\"pause again\\", /**/val);
-}
-
-/*bs*/try /**/{
-} catch (e) /**/{
-}
-
-/*bs*/with (e) /**/{}
-"
-`;
-
-exports[`Parser.pausePoints decorators 1`] = `
-"/*bs*/@annotation
-class MyClass { }
-"
-`;
-
-exports[`Parser.pausePoints flow 1`] = `
-"/*bs*/class App extends Component {
-  /*b*/renderHello(name: string, action: ReduxAction, { /**/todos }: Props) /**/{
-    /*bs*/return \`howdy \${name}\`;
-  /**/}
-}
-"
-`;
-
-exports[`Parser.pausePoints func 1`] = `
-"/*b*/function square(n) /**/{
-  /*bs*/return n * n;
-/**/}
-
-/*bs*/export /*b*/function exFoo() /**/{
-  /*bs*/return \\"yay\\";
-/**/}
-
-/*b*/async function slowFoo() /**/{
-  /*bs*/return \\"meh\\";
-/**/}
-
-/*bs*/export /*b*/async function exSlowFoo() /**/{
-  /*bs*/return \\"yay in a bit\\";
-/**/}
-
-/*b*/function ret() /**/{
-  /*bs*/return /*bs*/foo();
-/**/}
-
-/*bs*/child = /*b*/function() /**/{/**/};
-
-/*bs*/(/*b*/function() /**/{
-  2;
-/**/})();
-
-const /*bs*/obj = {
-  /**/foo: /*b*/function name() /**/{
-    2 + 2;
-  /**/},
-
-  /*b*/bar() /**/{
-    2 + 2;
-  /**/}
-};
-
-/*bs*/export default /*b*/function root() /**/{
-/**/}
-
-/*b*/function test(a1, /**/a2 = 45, /**/{ /**/a3, /**/a4, /**/a5: /*bs*/{ /**/a6: /**/a7 } = {} } = {}) /**/{
-  /*bs*/console./*bs*/log(/**/\\"pause next here\\");
-/**/}
-
-/*b*/() => (/*bs*/x = 4/**/);
-
-/*b*/function ret2() /**/{
-  /*bs*/return (
-    /*bs*/foo()
-  );
-/**/}
-"
-`;
-
-exports[`Parser.pausePoints html 1`] = `
-"<html>
-<head>
-	<script type=\\"text/javascript\\">
-		var /*bs*/globalObject = {
-			/**/first: /**/\\"name\\",
-			/**/last: /**/\\"words\\"
-		};
-		/*b*/function sayHello (name) /**/{
-			/*bs*/return \`Hello, \${name}!\`;
-		/**/}
-	</script>
-	<style>
-		BODY {
-			font-size: 48px;
-			color: rebeccapurple;
-		}
-	</style>
-</head>
-<body>
-	<h1>Testing Script Tags in HTML</h1>
-	<script>
-		const /*bs*/capitalize = /*b*/name => /**/{
-			/*bs*/return /*bs*/name[0]./*bs*/toUpperCase() + /*bs*/name./*bs*/substring(/**/1)
-		/**/};
-		const /*bs*/greetAll = /**/[/**/\\"my friend\\", /**/\\"buddy\\", /**/\\"world\\"]
-			./*bs*/map(/**/capitalize)
-			./*bs*/map(/**/sayHello)
-			./*bs*/join(/**/\\"\\\\n\\");
-
-		/*bs*/globalObject.greetings = greetAll;
-	</script>
-	<p>
-		Some arbitrary intermediate content to affect the offsets of the scripts
-	</p>
-	<script>
-		/*bs*/(/*b*/function iife() /**/{
-			const /*bs*/greeting = /*bs*/sayHello(/**/\\"Ryan\\");
-			/*bs*/console./*bs*/log(/**/greeting);
-		/**/})();
-	</script>
-</body>
-</html>
-"
-`;
-
-exports[`Parser.pausePoints jsx 1`] = `
-"const /*bs*/jsxElement = /*bs*/<h1>/**/ Hi ! I'm here ! /**/</h1>;
-
-/*bs*/<div id=\\"3\\" res={/*b*/foo()}>/**/
-  /*b*/<Item>/**/{/*bs*/foo()}/**/</Item>/**/
-/**/</div>
-"
-`;
-
-exports[`Parser.pausePoints modules 1`] = `
-"/*bs*/import {x} from \\"y\\"
-/*bs*/import z from \\"y\\";
-
-/*bs*/export /*bs*/class AppComponent {
-  /*b*/title = 'app'
-}
-
-/*bs*/export default /*bs*/class AppComponent {
-  /*b*/title = 'app'
-}
-"
-`;
-
-exports[`Parser.pausePoints statements 1`] = `
-"/*bs*/debugger; /*bs*/debugger;
-/*bs*/console./*bs*/log(/**/\\"a\\"); /*bs*/console./*bs*/log(/**/\\"a\\");
-
-// assignments with valid pause locations
-/*bs*/this.x = 3;
-var /*bs*/a = 4;
-var /*bs*/d = /**/[/*bs*/foo()]
-var /*bs*/f = 3, /*bs*/e = 4;
-var /*bs*/g = /**/[], /*bs*/h = {};
-
-// assignments with invalid pause locations
-var /*bs*/b = /*bs*/foo();
-/*bs*/c = /*bs*/foo();
-
-
-const /*bs*/arr = /**/[
-  /**/'1',
-  /**/2,
-  /*bs*/foo()
-]
-
-const /*bs*/obj = {
-  /**/a: /**/'1',
-  /**/b: /**/2,
-  /**/c: /*bs*/foo(),
-}
-
-/*bs*/foo(
-  /**/1,
-  /*bs*/foo(
-    /**/1
-  ),
-  /**/3
-)
-
-/*bs*/throw new Error(\\"3\\");
-3;
-
-/*bs*/while (/*bs*/i < 6) /**/{ /*bs*/break }
-/*bs*/while (/*bs*/i < 6) /**/{ /*bs*/continue;}
-"
-`;