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

Unified Diff: issue-reporter.js

Issue 29595588: Issue 5952 - Clicking Cancel in the issue reporter doesn't close the tab (Closed) Base URL: https://hg.adblockplus.org/adblockplusui/
Patch Set: Created Nov. 2, 2017, 11:39 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 | messageResponder.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: issue-reporter.js
===================================================================
--- a/issue-reporter.js
+++ b/issue-reporter.js
@@ -27,17 +27,17 @@ let pages = {
commentPage: [initCommentPage, leaveCommentPage],
sendPage: [initSendPage, leaveSendPage]
};
document.addEventListener("DOMContentLoaded", () =>
{
document.getElementById("cancel").addEventListener("click", () =>
{
- window.close();
+ closeMe();
});
document.getElementById("continue").addEventListener("click", () =>
{
if (!document.getElementById("continue").disabled)
pages[getCurrentPage()][1]();
});
@@ -58,16 +58,24 @@ document.addEventListener("DOMContentLoa
}).then(url =>
{
document.getElementById("privacyPolicy").href = url;
});
initDataCollector();
});
+function closeMe()
+{
+ browser.runtime.sendMessage({
+ type: "app.get",
+ what: "senderId"
+ }).then(tabId => browser.tabs.remove(tabId));
Thomas Greiner 2017/11/02 12:39:51 Wouldn't it make more sense to leave it up to the
Wladimir Palant 2017/11/02 13:16:51 That's the approach I chose initially but so far w
Thomas Greiner 2017/11/02 14:13:02 Not sure either whether this choice was made inten
+}
+
function getCurrentPage()
{
return document.querySelector(".page:not([hidden])").id;
}
function setCurrentPage(pageId)
{
if (!pages.hasOwnProperty(pageId))
@@ -244,17 +252,17 @@ function initDataCollector()
return Promise.all(handlers);
}).then(() =>
{
setCurrentPage("typeSelectorPage");
}).catch(e =>
{
console.error(e);
alert(e);
- window.close();
+ closeMe();
});
}
function initTypeSelector()
{
document.getElementById("typeFalsePositive").focus();
@@ -494,10 +502,10 @@ function initSendPage()
progress.value = event.loaded;
}
});
request.send(serializeReportData());
}
function leaveSendPage()
{
- window.close();
+ closeMe();
}
« no previous file with comments | « no previous file | messageResponder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld