Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: popup.js

Issue 29785555: Issue 6684 - Issue Reporter Active Tab Screenshot (Closed)
Patch Set: using active + inlined object literal Created May 22, 2018, 4:13 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: popup.js
===================================================================
--- a/popup.js
+++ b/popup.js
@@ -98,22 +98,42 @@
activateClickHide.timeout = null;
}
document.body.classList.remove("clickhide-active");
browser.tabs.sendMessage(tab.id, {type: "composer.content.finished"});
}
function reportIssue()
{
- browser.tabs.create({
- url: browser.runtime.getURL("/issue-reporter.html?" + tab.id)
- }).then(() =>
- {
- window.close();
- });
+ // capture the current visible tab
Sebastian Noack 2018/05/23 14:48:59 Nit: This comment seems superfluous (it essentiall
a.giammarchi 2018/05/23 15:06:35 Done.
+ browser.tabs.captureVisibleTab(
+ null,
+ {format: "png"},
+ (screenshot) =>
Sebastian Noack 2018/05/23 14:48:59 Nit: We omit the optional parenthesis in arrow fun
a.giammarchi 2018/05/23 15:06:35 Done.
+ {
+ // setup a listener to provide once tab url
+ // and base64 screenshot data once asked
+ browser.runtime.onMessage.addListener(
+ function onMessage(event)
+ {
+ if (event.type === "issue-reporter")
Sebastian Noack 2018/05/23 14:48:59 Nit: We prefer == over ===, as per the Mozilla cod
a.giammarchi 2018/05/23 15:06:35 Done.
+ {
+ browser.runtime.onMessage.removeListener(onMessage);
+ return Promise.resolve({url: tab.url, screenshot});
+ }
+ }
+ );
+
+ // create an active/selected issue reporter tab
Sebastian Noack 2018/05/23 14:48:59 Nit: This comment seems superfluous as well.
a.giammarchi 2018/05/23 15:06:36 Done.
+ browser.tabs.create({
+ active: true,
+ url: browser.runtime.getURL("/issue-reporter.html?" + tab.id)
+ });
+ }
+ );
}
function toggleCollapse(event)
{
let collapser = event.currentTarget;
let collapsible = document.getElementById(collapser.dataset.collapsible);
collapsible.classList.toggle("collapsed");
togglePref(collapser.dataset.option);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld