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: Created May 18, 2018, 10:33 a.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,45 @@
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
+ browser.tabs.captureVisibleTab(
Sebastian Noack 2018/05/22 15:28:59 I suppose we also have to add a new permission for
a.giammarchi 2018/05/22 15:55:31 AFAIK there's no need for extra permission, tabs w
Sebastian Noack 2018/05/22 16:01:10 Oh cool, never mind then.
+ null,
+ {format: "png"},
+ (screenshot) =>
+ {
+ // 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")
+ {
+ browser.runtime.onMessage.removeListener(onMessage);
+ return Promise.resolve({
+ url: tab.url,
+ screenshot
Sebastian Noack 2018/05/22 15:28:59 Nit: It appears that this literal would fit on one
a.giammarchi 2018/05/22 16:14:09 Done.
+ });
+ }
+ }
+ );
+
+ // create an active/selected issue reporter tab
+ browser.tabs.create({
+ selected: true,
Sebastian Noack 2018/05/22 15:28:59 The "selected" property is deprecated, use "active
a.giammarchi 2018/05/22 15:55:31 Should I use both to be sure it works? I think I u
Sebastian Noack 2018/05/22 16:01:10 That is not necessary, "active" was introduced lon
a.giammarchi 2018/05/22 16:14:08 Done.
+ 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