Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

map selected source when we toggle pretty print#3285

Merged
codehag merged 9 commits into
firefox-devtools:masterfrom
jasonLaster:pretty-print-original-source
Aug 3, 2017
Merged

map selected source when we toggle pretty print#3285
codehag merged 9 commits into
firefox-devtools:masterfrom
jasonLaster:pretty-print-original-source

Conversation

@jasonLaster
Copy link
Copy Markdown
Contributor

Associated Issue: #2883

Summary of Changes

  • unwraps the promise middleware
  • adds some selected location mapping

Test Plan

updating the mochitest now

@jasonLaster jasonLaster force-pushed the pretty-print-original-source branch from b822558 to 766b46e Compare July 7, 2017 17:17
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 7, 2017

Codecov Report

Merging #3285 into master will decrease coverage by 0.04%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #3285      +/-   ##
=========================================
- Coverage   49.35%   49.3%   -0.05%     
=========================================
  Files          99      99              
  Lines        4156    4160       +4     
  Branches      856     857       +1     
=========================================
  Hits         2051    2051              
- Misses       2105    2109       +4
Impacted Files Coverage Δ
src/actions/sources.js 49.68% <0%> (-1.29%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3e9125...2961e56. Read the comment docs.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 7, 2017

Codecov Report

Merging #3285 into master will increase coverage by 0.32%.
The diff coverage is 21.81%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #3285      +/-   ##
=========================================
+ Coverage   51.97%   52.3%   +0.32%     
=========================================
  Files         110     112       +2     
  Lines        4529    4562      +33     
  Branches      936     940       +4     
=========================================
+ Hits         2354    2386      +32     
- Misses       2175    2176       +1
Impacted Files Coverage Δ
src/utils/source.js 66.19% <0%> (+15.37%) ⬆️
src/reducers/breakpoints.js 72.85% <0%> (-9.41%) ⬇️
src/actions/breakpoints.js 78.82% <0%> (-4.93%) ⬇️
src/actions/breakpoints/remapLocations.js 0% <0%> (ø)
src/utils/editor/index.js 11.36% <0%> (+1.36%) ⬆️
src/actions/sources.js 68.18% <8.33%> (+1.51%) ⬆️
src/actions/sources/createPrettySource.js 91.66% <91.66%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 57bf165...ec2d078. Read the comment docs.

Copy link
Copy Markdown
Contributor

@codehag codehag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! maybe we can write a test for this flow?

@codehag
Copy link
Copy Markdown
Contributor

codehag commented Jul 10, 2017

Mochi test needs an update

@codehag
Copy link
Copy Markdown
Contributor

codehag commented Jul 10, 2017

I will take a look at getting that mochitest up and running / add a test!

@codehag
Copy link
Copy Markdown
Contributor

codehag commented Jul 11, 2017

Not too sure what is going on... I have spent a few hours on it. But it looks like the highlighting of the line in pretty print is not working when you run the test. Maybe its worth another look? Full output of the error:

The following tests failed:
191 INFO TEST-UNEXPECTED-FAIL | devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-paused.js | undefined assertion name - Got server1.conn0.child1/source29, expected server1.conn0.child1/source29/originalSource-d096ee6b9228104ac049e96c5926c143
Stack trace:
    chrome://mochikit/content/browser-test.js:test_is:983
    chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/head.js:assertPausedLocation:221
    chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-paused.js:null:20
    Tester_execTest@chrome://mochikit/content/browser-test.js:774:9
    Tester.prototype.nextTest</<@chrome://mochikit/content/browser-test.js:686:7
    SimpleTest.waitForFocus/waitForFocusInner/focusedOrLoaded/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:795:59
192 INFO TEST-UNEXPECTED-FAIL | devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-paused.js | undefined assertion name - Got 2, expected 18
Stack trace:
    chrome://mochikit/content/browser-test.js:test_is:983
    chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/head.js:assertPausedLocation:222
    chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-paused.js:null:20
    Tester_execTest@chrome://mochikit/content/browser-test.js:774:9
    Tester.prototype.nextTest</<@chrome://mochikit/content/browser-test.js:686:7
    SimpleTest.waitForFocus/waitForFocusInner/focusedOrLoaded/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:795:59
193 INFO TEST-UNEXPECTED-FAIL | devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-paused.js | Line is highlighted as paused -
Stack trace:
    chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/head.js:assertPausedLocation:226
    chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-paused.js:null:20
    Tester_execTest@chrome://mochikit/content/browser-test.js:774:9
    Tester.prototype.nextTest</<@chrome://mochikit/content/browser-test.js:686:7
    SimpleTest.waitForFocus/waitForFocusInner/focusedOrLoaded/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:795:59
194 INFO TEST-UNEXPECTED-FAIL | devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-paused.js | undefined assertion name - Got server1.conn0.child1/source29, expected server1.conn0.child1/source29/originalSource-d096ee6b9228104ac049e96c5926c143
Stack trace:
    chrome://mochikit/content/browser-test.js:test_is:983
    chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/head.js:assertPausedLocation:221
    debugger eval code:null:1
    chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-paused.js:null:22
    Tester_execTest@chrome://mochikit/content/browser-test.js:774:9
    Tester.prototype.nextTest</<@chrome://mochikit/content/browser-test.js:686:7
    SimpleTest.waitForFocus/waitForFocusInner/focusedOrLoaded/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:795:59
195 INFO TEST-UNEXPECTED-FAIL | devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-paused.js | undefined assertion name - Got 2, expected 18
Stack trace:
    chrome://mochikit/content/browser-test.js:test_is:983
    chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/head.js:assertPausedLocation:222
    debugger eval code:null:1
    chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-paused.js:null:22
    Tester_execTest@chrome://mochikit/content/browser-test.js:774:9
    Tester.prototype.nextTest</<@chrome://mochikit/content/browser-test.js:686:7
    SimpleTest.waitForFocus/waitForFocusInner/focusedOrLoaded/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:795:59
196 INFO TEST-UNEXPECTED-FAIL | devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-paused.js | Line is highlighted as paused -
Stack trace:
    chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/head.js:assertPausedLocation:226
    debugger eval code:null:1
    chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-paused.js:null:22
    Tester_execTest@chrome://mochikit/content/browser-test.js:774:9
    Tester.prototype.nextTest</<@chrome://mochikit/content/browser-test.js:686:7
    SimpleTest.waitForFocus/waitForFocusInner/focusedOrLoaded/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:795:59
197 INFO TEST-UNEXPECTED-FAIL | devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-paused.js | This test exceeded the timeout threshold. It should be rewritten or split up. If that's not possible, use requestLongerTimeout(N), but only as a last resort. -
Buffered messages finished
SUITE-END | took 83s

@codehag
Copy link
Copy Markdown
Contributor

codehag commented Jul 31, 2017

So I have narrowed down why this is failing:

  • if a source has not been pretty printed before, the breakpoint is not aware that there is anything other than a generated source. Once a pretty printed source exists, the breakpoint is also associated with the PP source.

Another issue I noticed: if the PP file is closed there is no way to reopen it. I will look into these two for a little bit and see if i can resolve these two issues.

@codehag codehag force-pushed the pretty-print-original-source branch from 2961e56 to 7a2769b Compare July 31, 2017 14:56
@codehag codehag changed the base branch from master to next July 31, 2017 14:57
Comment thread src/reducers/breakpoints.js Outdated
case "ADD_PRETTY_SOURCE": {
const { source, generatedSource, mappings } = action;

function updateLocation({ location }) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can move this out of the reducer, wanted a bit of feedback on it though if it would be too slow

@jasonLaster jasonLaster changed the base branch from next to master August 1, 2017 18:44
@codehag codehag force-pushed the pretty-print-original-source branch from ca0b78a to 05d0e08 Compare August 2, 2017 13:33
Comment thread src/actions/sources.js Outdated
*/
export function selectSource(id: string, options: SelectSourceOptions = {}) {
return async ({ dispatch, getState, client }: ThunkArgs) => {
return ({ dispatch, getState, sourceMaps, client }: ThunkArgs) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah we don't need sourcemaps here


clickElement(dbg, "prettyPrintButton");
yield waitForDispatch(dbg, "TOGGLE_PRETTY_PRINT");
debugger;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops

Comment thread src/actions/breakpoints.js Outdated
};
}

function remapLocations(breakpoints, sourceId, sourceMaps) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does async function work?

If so, can we add an await here. I'm guessing no because I bet the Promise.all was a hack lol

Copy link
Copy Markdown
Contributor

@codehag codehag Aug 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The promise api is still useful in async await, and promise.all is the suggested way to resolve a group of promises. i never had to use it before, and it was a stumbling block. Async/Await can resolve single promises, but not a collection. infos --> tc39/proposal-async-await#61

sourceMaps
);

return dispatch({
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this reads really well!

Copy link
Copy Markdown
Contributor Author

@jasonLaster jasonLaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great

};
}

export function remapBreakpoints(sourceId: string) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think of moving remapBreakpoints to actions/breakpoints/remapBreakpoints?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the locations

Comment thread src/actions/sources.js Outdated
frames = await updateFrameLocations(frames, sourceMaps);
}
if (!prettySource) {
await dispatch(createPrettySource(sourceId));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we do:

const prettySource = await dispatch(createPrettySource(sourceId));

expect(pretty.get("contentType")).toEqual("text/javascript");
expect(pretty.get("url").includes(prettyURL)).toEqual(true);
expect(pretty).toMatchSnapshot();
});
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about we add two more tests

  1. also has breakpoints mapped
  2. also has selected location mapped

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didnt have time to do this, and there was an unusual error so I made a ticket to tackle it later: #3531

Comment thread src/components/SymbolModal.css Outdated

.theme-dark .symbol-modal {
box-shadow: 2px 4px 6px var(--popup-shadow-color);
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebasesss

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops what was lost?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's now in modal.css

Comment thread src/reducers/breakpoints.js Outdated
return state.setIn(["breakpoints", locationId], breakpoint);
}

function remapBreakpoint(state, action) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remapBreakpoint -> remapBreakpoints

@codehag codehag force-pushed the pretty-print-original-source branch 2 times, most recently from 77a6deb to 87ef289 Compare August 2, 2017 17:11
Copy link
Copy Markdown
Contributor Author

@jasonLaster jasonLaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@codehag codehag force-pushed the pretty-print-original-source branch from 87ef289 to ec2d078 Compare August 3, 2017 08:02
@codehag codehag merged commit d7648b7 into firefox-devtools:master Aug 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants