Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Compute sourceRoot when only relative URLs are seen#698

Merged
tromey merged 1 commit intofirefox-devtools:masterfrom
tromey:relative-source-urls
Sep 20, 2017
Merged

Compute sourceRoot when only relative URLs are seen#698
tromey merged 1 commit intofirefox-devtools:masterfrom
tromey:relative-source-urls

Conversation

@tromey
Copy link
Contributor

@tromey tromey commented Sep 19, 2017

Currently _setSourceMapRoot bails if the source map contains all the
sources. However, this is not valid according to the source map spec;
and the debugger doesn't work properly with the returned URLs. On the
other hand, some source maps have non-URLs like "webpack:/bootstrap",
which we do want to treat as absolute. So, this patch works around
the problem by examining the URLs in a mildly lax way.
Fixes #356

Associated Issue: #

Summary of Changes

  • change 1
  • change 2

Test Plan

Tell us a little a bit about how you tested your patch.

Example test plan:

  • Command-P opens the panel
  • Clicking “+” opens the panel
  • Clicking a source navigates to the source
  • Clicking "x" closes the panel

Screenshots/Videos (OPTIONAL)

@tromey tromey requested a review from jasonLaster September 19, 2017 19:58
Copy link
Contributor

@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.

Hmm, i think i might have seen this popup in a real world example:

firefox-devtools/debugger#3975

// URLs are relative. What's difficult is that we want to pretend
// that some non-URLs, like "webpack:/whatever", are actually URLs.
if (sourceMap.hasContentsOfAllSources() &&
sourceMap.sources.every(sourceName => URL_ISH.test(sourceName))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is minor, but can we move this to a temporary variable so that it is a bit more self documenting

const allURLsAreAbsolute = sourceMap.sources.every(sourceName => URL_ISH.test(sourceName)

test("Non-existing sourceRoot resolution with relative URLs", async () => {
const urls = await setupBundleFixture("noroot2");
expect(urls).toEqual(["http://example.com/heart.js"]);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm not really sure what this test is documenting. It might be nice to see the webpack example in a test as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other tests cover webpack -- I initially wrote my patch a different way, which is how I knew that I needed to do this regexp thing.

Do you want some other change here as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

i see. that's okay.

Currently _setSourceMapRoot bails if the source map contains all the
sources.  However, this is not valid according to the source map spec;
and the debugger doesn't work properly with the returned URLs.  On the
other hand, some source maps have non-URLs like "webpack:/bootstrap",
which we do want to treat as absolute.  So, this patch works around
the problem by examining the URLs in a mildly lax way.
Fixes firefox-devtools#356
@tromey tromey merged commit e2eda58 into firefox-devtools:master Sep 20, 2017
@tromey tromey deleted the relative-source-urls branch September 20, 2017 14:18
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.

[SourceMap] CNN generates a garbled source map

2 participants