Bug 1259186 - Send DOM event when feedback page is automatically loaded, instead of custom URL params. r=grisha a=ritu
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Wed, 23 Mar 2016 16:03:42 -0400
changeset 378810 ecb67929a43fcc530a454f50015af681d86774b0
parent 378809 93a53170dedffdff45bf9eb8dac6e5ef7a13c4ba
child 378811 55d9570b4520adff40c2362d2e027655f4271f7a
push id21011
push usermak77@bonardo.net
push dateThu, 16 Jun 2016 13:40:45 +0000
reviewersgrisha, ritu
bugs1259186
milestone47.0
Bug 1259186 - Send DOM event when feedback page is automatically loaded, instead of custom URL params. r=grisha a=ritu MozReview-Commit-ID: 6swre6VYpdz
mobile/android/chrome/content/Feedback.js
--- a/mobile/android/chrome/content/Feedback.js
+++ b/mobile/android/chrome/content/Feedback.js
@@ -21,16 +21,25 @@ var Feedback = {
       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);
     browser.addEventListener("FeedbackOpenPlay", 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) {