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

Respect enable extenstions setting in Sources and QuickOpenModal - #7705

Merged
darkwing merged 17 commits into
firefox-devtools:masterfrom
konradk:hide-extenstions
Jan 22, 2019
Merged

Respect enable extenstions setting in Sources and QuickOpenModal#7705
darkwing merged 17 commits into
firefox-devtools:masterfrom
konradk:hide-extenstions

Conversation

@konradk

@konradk konradk commented Jan 10, 2019

Copy link
Copy Markdown
Contributor

Fixes #7531

Summary of Changes

  • add default preference in development environment: "devtools.chrome.enabled" as "false"
  • filter sources by extenstions when "devtools.chrome.enabled" is "false"

Test Plan

  • Add extenstion
  • Turn off "Enable browser chrome and add-on debugging toolboxes" preferece
  • Source list shouldn't list extensions
  • QuickOpenModal shouldn't list extenstions

My questions:

  • I've only edited newSources action, because that's only action I've seen in development mode. Is there any other action I should edit - e.g. newSource?
  • Is there better way to identify extension than url.startsWith("moz-extension://"))?

To do:

  • fix mochitests browser_dbg-content-script-sources.js
  • fix mochitests browser_dbg-sources-arrow-keys.js
  • Update test snapshots
  • Support extension prefix with single slash
  • fix type errors

@jasonLaster jasonLaster left a comment

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.

Thanks! This looks great!

Perhaps we can add some unit tests n SourcesTree.spec.js and QuickOpen.spec.js

Comment thread src/actions/sources/newSources.js Outdated
sources = sources.filter(
source => !(source.url && source.url.startsWith("moz-extension://"))
);
}

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 think we could move this flag to a selector like getRelativeSources, which will just decide what is shown in the tree and modal.

Comment thread src/client/firefox/create.js Outdated
relativeUrl: source.url,
isPrettyPrinted: false,
isWasm: false,
isExtension: source.url && source.url.startsWith("moz-extension://"),

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.

Does this address the extensions from Chrome browser?

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.

No, I've just fixes that - fixed regexp and moved this set to common source action creator

@konradk

konradk commented Jan 12, 2019

Copy link
Copy Markdown
Contributor Author

@jasonLaster Currently filtering extensions is the responsibility of getRelativeSources selector. I don't see the possibility to add the test for this enhancement in SourceTree or QuickOpenModal specs, because it's not their responsibility to filter them.

I've prepared the reducers test here, but I'm not sure if it's a good approach.

Edit: I'll update snapshots (missing isExtension property) after confirmation that it is a good idea.

@jasonLaster

Copy link
Copy Markdown
Contributor

this looks good

@jasonLaster

Copy link
Copy Markdown
Contributor

failed test: devtools/client/debugger/new/test/mochitest/browser_dbg-content-script-sources.js
failed test: devtools/client/debugger/new/test/mochitest/browser_dbg-sources-arrow-keys.js

two mochitests fail -- hopefully the errors are easy to follow...

Comment thread src/utils/source.js Outdated
}

export function isUrlExtension(url: string) {
return /^(chrome|moz)-extension:\/\//.test(url);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@konradk Just a heads up: I also have at least one extension (namely User Agent Switcher) whose scheme seems to end by only one trailing slash and not two. The above regex tests with two trailing slashes at the end.

See screenshot:

image

Pinging also @AnshulMalik because I think this is probably relevant for https://bugzilla.mozilla.org/show_bug.cgi?id=1518221 as well.

Note sure how to handle this (and why this is under blob://) but testing against

// one trailing slash
return /^(chrome|moz)-extension:\//.test(url);

and not

// two trailing slashes
return /^(chrome|moz)-extension:\/\//.test(url);

would be worthwhile.

If so, probably also good if a test would be added for this edge case.

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.

@gerdneuman Nice catch, I will fix that.

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.

Not sure why it's blob and has just one /

@darkwing

Copy link
Copy Markdown
Contributor

Excellent work @konradk ! Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sources and QuickOpenModal should respect Enable add-on debugging setting

6 participants