Bug 1259186 - Send DOM event when feedback page is automatically loaded, instead of custom URL params. r=grisha
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Wed, 23 Mar 2016 16:03:42 -0400
changeset 331641 c7985389034d03f3e13db28dcd31c94912af550a
parent 331640 f4ab4fd96f8ef68158a4cae1e5dae91e6b52da35
child 331642 a8aba803fab574bd5ace7482ef4e62334002e576
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgrisha
bugs1259186
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1259186 - Send DOM event when feedback page is automatically loaded, instead of custom URL params. r=grisha MozReview-Commit-ID: 6swre6VYpdz
mobile/android/chrome/content/Feedback.js
--- a/mobile/android/chrome/content/Feedback.js
+++ b/mobile/android/chrome/content/Feedback.js
@@ -18,18 +18,28 @@ var Feedback = {
     // Don't prompt for feedback in distribution builds.
     try {
       Services.prefs.getCharPref("distribution.id");
       return;
     } catch (e) {}
 
     let url = this._feedbackURL;
     let browser = BrowserApp.selectOrAddTab(url, { parentId: BrowserApp.selectedTab.id }).browser;
+
     browser.addEventListener("FeedbackClose", this, false, true);
     browser.addEventListener("FeedbackMaybeLater", this, false, true);
+
+    // Dispatch a custom event to the page content when feedback is prompted by the browser.
+    // This will be used by the page to determine it's being loaded directly by the browser,
+    // instead of by the user visiting the page, e.g. through browser history.
+    function loadListener(event) {
+      browser.removeEventListener("DOMContentLoaded", loadListener, false);
+      browser.contentDocument.dispatchEvent(new CustomEvent("FeedbackPrompted"));
+    }
+    browser.addEventListener("DOMContentLoaded", loadListener, false);
   },
 
   handleEvent: function(event) {
     if (!this._isAllowed(event.target)) {
       return;
     }
 
     switch (event.type) {