Commit 9b3b0680 authored by Cosmin Sabou's avatar Cosmin Sabou
Browse files

Backed out 2 changesets (bug 1770204, bug 1770205) for devtools faolires on...

Backed out 2 changesets (bug 1770204, bug 1770205) for devtools faolires on browser_dbg-html-breakpoints.js. CLOSED TREE

Backed out changeset ad44d2e50491 (bug 1770205)
Backed out changeset a1459819402b (bug 1770204)
parent 16b34baf
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -25,13 +25,11 @@ Array [
        "thread": "FakeThread",
      },
    ],
    "filename": "a",
    "source": Object {
      "extensionName": null,
      "id": "a",
      "isBlackBoxed": false,
      "isExtension": false,
      "isHTML": false,
      "isOriginal": false,
      "isPrettyPrinted": false,
      "isWasm": false,
@@ -43,8 +41,12 @@ Array [
]
`;

exports[`breakpoints should not re-add a breakpoint 1`] = `Array []`;

exports[`breakpoints should not show a breakpoint that does not have text 1`] = `Array []`;

exports[`breakpoints should not show a breakpoint that does not have text 2`] = `Array []`;

exports[`breakpoints should remap breakpoints on pretty print 1`] = `
Object {
  "disabled": false,
@@ -93,13 +95,11 @@ Array [
        "thread": "FakeThread",
      },
    ],
    "filename": "a",
    "source": Object {
      "extensionName": null,
      "id": "a",
      "isBlackBoxed": false,
      "isExtension": false,
      "isHTML": false,
      "isOriginal": false,
      "isPrettyPrinted": false,
      "isWasm": false,
+29 −1
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@ Object {
  "id": "base.js/originalSource-36c718d4bde9a75edb388ff7733efe7f",
  "isBlackBoxed": false,
  "isExtension": false,
  "isHTML": false,
  "isOriginal": true,
  "isPrettyPrinted": true,
  "isWasm": false,
@@ -29,3 +28,32 @@ Object {
  },
}
`;

exports[`sources - pretty print should create a source when first toggling pretty print 1`] = `
Object {
  "extensionName": null,
  "id": "base.js/originalSource-36c718d4bde9a75edb388ff7733efe7f",
  "isBlackBoxed": false,
  "isExtension": false,
  "isOriginal": true,
  "isPrettyPrinted": true,
  "isWasm": false,
  "relativeUrl": "/examples/base.js:formatted",
  "thread": "FakeThread",
  "url": "http://localhost:8000/examples/base.js:formatted",
}
`;

exports[`sources - pretty print should create a source when first toggling pretty print 2`] = `
Object {
  "state": "fulfilled",
  "value": Object {
    "contentType": "text/javascript",
    "type": "text",
    "value": "function base() {
  return base
}
",
  },
}
`;
+0 −6
Original line number Diff line number Diff line
@@ -192,7 +192,6 @@ export function createGeneratedSource(sourceResource) {
    isWasm: !!features.wasm && sourceResource.introductionType === "wasm",
    isExtension:
      (sourceResource.url && isUrlExtension(sourceResource.url)) || false,
    isHTML: !!sourceResource.isInlineSource,
  });
}

@@ -211,7 +210,6 @@ function createSourceObject({
  isExtension = false,
  isPrettyPrinted = false,
  isOriginal = false,
  isHTML = false,
}) {
  return {
    // The ID, computed by:
@@ -244,10 +242,6 @@ function createSourceObject({
    // True if WASM is enabled *and* the generated source is a WASM source
    isWasm,

    // True is this source is an HTML and relates to many sources actors,
    // one for each of its inline <script>
    isHTML,

    // True, if this is an original pretty printed source
    isPrettyPrinted,

+11 −3
Original line number Diff line number Diff line
@@ -15,7 +15,10 @@ import actions from "../../../actions";
import { getSelectedLocation } from "../../../utils/selected-location";
import { createHeadlessEditor } from "../../../utils/editor/create-editor";

import { makeBreakpointId } from "../../../utils/breakpoint";
import {
  makeBreakpointId,
  sortSelectedBreakpoints,
} from "../../../utils/breakpoint";

import { getSelectedSource, getBreakpointSources } from "../../../selectors";

@@ -85,18 +88,23 @@ class Breakpoints extends Component {
    }

    const editor = this.getEditor();
    const sources = breakpointSources.map(({ source }) => source);
    const sources = [...breakpointSources.map(({ source }) => source)];

    return (
      <div className="pane breakpoints-list">
        {breakpointSources.map(({ source, breakpoints }) => {
          const sortedBreakpoints = sortSelectedBreakpoints(
            breakpoints,
            selectedSource
          );

          return [
            <BreakpointHeading
              key={source.id}
              source={source}
              sources={sources}
            />,
            breakpoints.map(breakpoint => (
            ...sortedBreakpoints.map(breakpoint => (
              <Breakpoint
                breakpoint={breakpoint}
                source={source}
+35 −63
Original line number Diff line number Diff line
@@ -3,83 +3,55 @@
 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */

import { createSelector } from "reselect";
import { getSelectedSource, getSourcesMap } from "./sources";
import { getSelectedSource, getSourceFromId } from "./sources";
import { getBreakpointsList } from "./breakpoints";
import { getFilename } from "../utils/source";
import { getSelectedLocation } from "../utils/selected-location";
import { sortSelectedBreakpoints } from "../utils/breakpoint";

// Returns all the breakpoints for the given selected source
// Depending on the selected source, this will match original or generated
// location of the given selected source.
function _getBreakpointsForSource(visibleBreakpoints, source, selectedSource) {
  return visibleBreakpoints.filter(
function getBreakpointsForSource(source, selectedSource, breakpoints) {
  return sortSelectedBreakpoints(breakpoints, selectedSource)
    .filter(
      bp =>
        !bp.options.hidden &&
        (bp.text || bp.originalText || bp.options.condition || bp.disabled)
    )
    .filter(
      bp => getSelectedLocation(bp, selectedSource).sourceId == source.id
    );
}

// Returns a sorted list of sources for which we have breakpoints
// We will return generated or original source IDs based on the currently selected source.
const _getSourcesForBreakpoints = (breakpoints, sourcesMap, selectedSource) => {
  const breakpointSourceIds = breakpoints.map(
const getSourcesForBreakpoints = state => {
  const selectedSource = getSelectedSource(state);
  const breakpointSourceIds = getBreakpointsList(state).map(
    breakpoint => getSelectedLocation(breakpoint, selectedSource).sourceId
  );

  const sources = [];
  // We may have more than one breakpoint per sourceId,
  // so use a Set to have a unique list of source IDs.
  for (const sourceId of [...new Set(breakpointSourceIds)]) {
    const source = sourcesMap.get(sourceId);

    // Ignore any source that is no longer in the sources reducer
    // or blackboxed sources.
    if (!source || source.isBlackBoxed) {
      continue;
    }

    const bps = _getBreakpointsForSource(breakpoints, source, selectedSource);

    // Ignore sources which have no breakpoints
    if (bps.length === 0) {
      continue;
    }

    sources.push({
      source,
      breakpoints: bps,
      filename: getFilename(source),
    });
  }

  return sources.sort((a, b) => a.filename.localeCompare(b.filename));
  return [...new Set(breakpointSourceIds)]
    .map(sourceId => {
      const source = getSourceFromId(state, sourceId);
      const filename = getFilename(source);
      return { source, filename };
    })
    .filter(({ source }) => source && !source.isBlackBoxed)
    .sort((a, b) => a.filename - b.filename)
    .map(({ source }) => source);
};

// Returns a list of sources with their related breakpoints:
//   [{ source, breakpoints [breakpoint1, ...] }, ...]
//
// This only returns sources for which we have a visible breakpoint.
// This will return either generated or original source based on the currently
// selected source.
export const getBreakpointSources = createSelector(
  getBreakpointsList,
  getSourcesMap,
  getSourcesForBreakpoints,
  getSelectedSource,
  (breakpoints, sourcesMap, selectedSource) => {
    const visibleBreakpoints = breakpoints.filter(
      bp =>
        !bp.options.hidden &&
        (bp.text || bp.originalText || bp.options.condition || bp.disabled)
    );

    const sortedVisibleBreakpoints = sortSelectedBreakpoints(
      visibleBreakpoints,
      selectedSource
    );

    return _getSourcesForBreakpoints(
      sortedVisibleBreakpoints,
      sourcesMap,
      selectedSource
    );
  (breakpoints, sources, selectedSource) => {
    return sources
      .map(source => ({
        source,
        breakpoints: getBreakpointsForSource(
          source,
          selectedSource,
          breakpoints
        ),
      }))
      .filter(({ breakpoints: bps }) => bps.length > 0);
  }
);
Loading