Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve visibility of message to enable "Remote Debugging via USB" with web-ext run -t firefox-android #2038

Merged
merged 33 commits into from
Oct 9, 2020

Conversation

sonalprabhu
Copy link
Contributor

Fixes #1969
fix: Looped the "Check Remote Debugging is ON" warning and highlighted it
Screenshot (109)

src/extension-runners/firefox-android.js Outdated Show resolved Hide resolved
src/util/adb.js Outdated Show resolved Hide resolved
src/util/adb.js Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Oct 2, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling 3b5e1ca on sonalprabhu:loop-warning into 82c4250 on mozilla:master.

@rpl rpl changed the title Fix: Improve visibility of message to enable "Remote Debugging via USB" with web-ext run -t firefox-android fix: Improve visibility of message to enable "Remote Debugging via USB" with web-ext run -t firefox-android Oct 2, 2020
@rpl
Copy link
Member

rpl commented Oct 2, 2020

@sonalprabhu as a side note, don't worry about the audit-deps failure in the travis CI job, it is unrelated to the changes in this PR, we'll take care of that and you'll just need to rebase this PR once we merged a fix for it.

sonalprabhu and others added 21 commits October 2, 2020 17:26
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
@sonalprabhu sonalprabhu requested a review from rpl October 8, 2020 17:00
Copy link
Member

@rpl rpl left a comment

Choose a reason for hiding this comment

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

@sonalprabhu good job, this looks almost ready, there are just a few more tweaks needed (and a small fix to the test case, which is currently not failing even if it is expecting the wrong log level).

tests/unit/test-util/test.adb.js Outdated Show resolved Hide resolved
src/util/adb.js Show resolved Hide resolved
src/util/adb.js Outdated

while (rdpUnixSockets.length === 0) {
log.info(`\n${msg}\n`);
Copy link
Member

Choose a reason for hiding this comment

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

I think that we can remove the additional '\n' from this log message, they were meant to make that log to stand out and be more visible (which was clearly not enough :-P), now we are going to keep printing this message until we find the unix socket file and so we don't need this additional space.

Let's just change this into log.info(msg).

@@ -1129,6 +1131,44 @@ describe('utils/adb', () => {
);
});

it('informs the user if remote debugging is not enabled', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Nit, we don't really check if the remote debugging is enabled, we just wait for it to be available and so the description of this test may be a bit misleading, how about: it('reminds the user to enable remote debugging', ... instead?

Comment on lines 1150 to 1153
consoleStream.stopCapturing();
consoleStream.flushCapturedLogs();
consoleStream.startCapturing();
consoleStream.makeVerbose();
Copy link
Member

Choose a reason for hiding this comment

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

I think that the following tweaked version should be enough and slightly better:

      consoleStream.flushCapturedLogs(); <--- clear the captured logs
      consoleStream.makeVerbose(); <--- make the log verbose (to be able to assert the log level)
      consoleStream.startCapturing(); <--- make sure that we start capturing logs
      ...
      const promise = ... <-- get the promise
      await assert.isRejected(promise, WebExtError);  <--- wait the async function to complete
      ... // get the message that we expect by filtering the captured logs
      consoleStream.stopCapturing(); <--- stop capturing we don't need it anymore
      ... // assertions on the expected message and log level

Comment on lines 1147 to 1149
const maxDiscoveryTime = 50;
const retryInterval = 10;

Copy link
Member

Choose a reason for hiding this comment

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

Nit, let's remove this two consts and just pass the value in the call to adb.discoverRDPUnixSocket (we are not using them for any assertion and so we can make this test a bit shorter by making this small optional change).


assert.ok(capturedMessages.some(
(message) => (
message.match('[debug]') &&
Copy link
Member

Choose a reason for hiding this comment

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

Surprisingly this assertion doesn't seem to be fully working, the log we are expecting is emitted with log.info and so this test should actually fail and pass if we use '[info]' instead.

Another thing that we may also take care of is to make it clear when this test fails if the message wasn't found or wasn't emitted with the right log level, at the moment the two conditions are checked by a single assertion and so a failure would make it immediately clear.

Let's change this to get the message that we want using something like const foundMessage = consoleStream.caputedMessages.find((message) => message.includes(expectedMessage)), then check the two conditions in separate assertions:

      assert.ok(foundMessage);
      assert.ok(foundMessage &&
        foundMessage.includes(expectedLogLevel));

(NOTE: the foundMessage && foundMessage.includes is mainly needed to make the flow type checker happy ;-))

@rpl
Copy link
Member

rpl commented Oct 9, 2020

@sonalprabhu the last CI jobs did fail because of some trailing spaces in test.adb.js (added when you added back the empty line that was previously there):

You can fix that issue manually (by removing the trailing spaces and leave it as just an empty line as it was originally) or by running eslint --fix on that test file.

@rpl
Copy link
Member

rpl commented Oct 9, 2020

Can I create a new pull request? I am facing some problems with this branch

it would be better to don't create a new one, I can help you to figure out how to handle the issue (if you have still any issue on this branch), describe me what is the issue that you are facing and I'll look into it and provide you more hints on how to deal with it.

@sonalprabhu
Copy link
Contributor Author

sonalprabhu commented Oct 9, 2020

I cleared the issues with that.
Please re-review my PR

@rpl
Copy link
Member

rpl commented Oct 9, 2020

@sonalprabhu looks great! I just approved this version of the patch 🎉
Thanks a lot for taking care of this issue!

@rpl rpl merged commit 4ab3043 into mozilla:master Oct 9, 2020
@sonalprabhu
Copy link
Contributor Author

@sonalprabhu looks great! I just approved this version of the patch 🎉
Thanks a lot for taking care of this issue!

Thanks a lot for your detailed guidelines :)

@caitmuenster
Copy link

Thanks so much for the patch, @sonalprabhu! 🙌 Your contribution has been added to our recognition wiki.

Welcome onboard! We look forward to seeing you around the project.

@sonalprabhu sonalprabhu deleted the loop-warning branch October 10, 2020 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve visibility of message to enable "Remote Debugging via USB" with web-ext run -t firefox-android
4 participants