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

refactor badge.displayBrowserActionBadge to be used in messageHandler fixes #973 & refactoring pop.js to fixes #1513 #1523

Closed
wants to merge 7 commits into from

Conversation

Aishat-Akinyemi
Copy link

@Aishat-Akinyemi Aishat-Akinyemi commented Oct 10, 2019

#outreachy applicant fixes #973 and #1513

I refactored badge.displayBrowserActionBadge to be used in messageHandler. However my various attempts to reuse it in pop.js resulted in error, as the 'browser Action Badge' when clicked did not display anything.

Test
I set the number of container tabs that's required to show 'achievement' to 5 (I have changed this back to hundred after testing). The tests were successful.

Problem reusing in pop.js
The picture below is how I attempted to make badge.displayBrowserActionBadge to be used in pop.js that resulted in unexpected behaviour, kindly review and advise me on what the bugs could be, thank you. I have removed this code below from the pull request

image

Copy link
Collaborator

@maxxcrawford maxxcrawford left a comment

Choose a reason for hiding this comment

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

Be sure to run the linter. It will check the code and come back with errors for you to fix from the code you've added.

$ npm run lint

It's causing the build to fail.

Resolve submission Validation Warnings fixes #1513 #Outreachy2019/2020 Applicant
@Aishat-Akinyemi
Copy link
Author

Aishat-Akinyemi commented Oct 10, 2019 via email

@Aishat-Akinyemi
Copy link
Author

Aishat-Akinyemi commented Oct 10, 2019 via email

@Aishat-Akinyemi Aishat-Akinyemi changed the title refactor badge.displayBrowserActionBadge to be used in messageHandler… refactor badge.displayBrowserActionBadge to be used in messageHandler fixes #973 & refactoring pop.js to fixes #1513 Oct 11, 2019
@Aishat-Akinyemi
Copy link
Author

Aishat-Akinyemi commented Oct 12, 2019 via email

@groovecoder
Copy link
Member

Oh dang, this change has some conflicting changes now. @Aishat-Akinyemi - can you resolve them?

@@ -187,7 +181,7 @@ const messageHandler = {
// https://bugzil.la/1314674
// https://github.com/mozilla/testpilot-containers/issues/608
// ... so re-call displayBrowserActionBadge on window changes
badge.displayBrowserActionBadge();
badge.displayBrowserActionBadge("remove");
Copy link
Member

Choose a reason for hiding this comment

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

This action is actually "showVersionIndicator". We (ab)use it to get around https://bugzilla.mozilla.org/show_bug.cgi?id=1314674 but it looks like that bug is fixed now? So we can just remove this call now.

Copy link
Author

Choose a reason for hiding this comment

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

@groovecoder okay, so I should only focus on refactoring badge.displayBrowserActionBadge to handle

  1. when the user opens the 100th container and;
  2. line 5 in badge.js

Copy link
Member

Choose a reason for hiding this comment

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

Yup, that sounds right. And line 5 in badge.js is the "showVersionIndicator" action.

Copy link
Author

Choose a reason for hiding this comment

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

thank you, I have effected the changes

browser.browserAction.setBadgeBackgroundColor({color: color});
browser.browserAction.setBadgeText({text: text});
}
if(action==="remove") {
Copy link
Member

Choose a reason for hiding this comment

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

Please change this action to showVersionIndicator and then update the call on line 5 to use it.

Copy link
Author

Choose a reason for hiding this comment

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

@groovecoder thanks for the feedback. Please tell me what is meant by showVersionIndicator do you mean I should change the parameter action to showVersionIndicator?

Does the showversionindicator: get the version of the browser tab (in line 5 that will be incognito and in the messageHandler.js, that will be the 100th container tab)?

Copy link
Member

Choose a reason for hiding this comment

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

Here, change it to action==="showVersionIndicator" and on line 5, change the call to pass "showVersionIndicator"

Copy link
Author

Choose a reason for hiding this comment

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

thank you, I have effected the changes

@@ -610,7 +610,15 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
const siteSettings = await Logic.getAssignment(currentTab);
this.setupAssignmentCheckbox(siteSettings, currentTabUserContextId);
const currentPage = document.getElementById("current-page");
currentPage.innerHTML = escaped`<span class="page-title truncate-text">${currentTab.title}</span>`;
//using DOMParser to modify innerHTML
Copy link
Member

Choose a reason for hiding this comment

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

@jonathanKingston - is DOMParser the best replacement for innerHTML assignment?

Copy link
Author

Choose a reason for hiding this comment

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

Should I create a separate PR for the issues, I thought I could submit them both but since you are still assessing whether DOMParser is the best replacement what would you advise that I do?
I also think that it would make them count as 2 separate contributions on Outreachy.
Thank you

Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't ever be used, it's not any safer than innerHTML in fact it breaks the linting which captures when we use escaped. I don't think this is a good idea at all.

@Aishat-Akinyemi
Copy link
Author

Aishat-Akinyemi commented Oct 17, 2019 via email

const currentWindow = await browser.windows.getCurrent();
this.displayBrowserActionBadge(currentWindow.incognito);
const showVersionIndicator = await browser.windows.getCurrent();
this.displayBrowserActionBadge(showVersionIndicator);
Copy link
Member

Choose a reason for hiding this comment

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

You need to pass the string "showVersionIndicator" here, and you don't need the currentWindow variable anymore, because it was only used to pass the incognito property value, which isn't needed anymore. So you can just replace these 2 lines with:

this.displayBrowserActionBadge("showVersionIndicator");

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, I have done this. I opened a new PR #1561 that fixes #973 this issue only (and all the changes you requested in this PR have been implemented there).

I plan to submit a new PR that addresses #1513

Copy link
Contributor

@jonathanKingston jonathanKingston left a comment

Choose a reason for hiding this comment

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

Please remove the DOMParser changes as it reduces the ability to capture security issues.

@kendallcorner
Copy link
Collaborator

Looks like a new PR was submitted for this, so I will close, but let me know I am misunderstanding.

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.

Refactor badge.displayBrowserActionBadge to be used in both popup.js and messageHandler.js
5 participants