Bug 959230 - Use DOMWindowCreated events to add payments listeners. r=mfinkle, a=sledru
authorWes Johnston <wjohnston@mozilla.com>
Wed, 05 Feb 2014 12:15:44 -0800
changeset 176888 0dc5c205f684ee09aea3c0bf87010e567c1a7774
parent 176887 df84666ed37f9efee86a3b97c3daaef68a6ee651
child 176889 3a65ec0ec32439002894174bfa7ee36c95c8f09b
push id5189
push userryanvm@gmail.com
push dateThu, 06 Feb 2014 16:49:07 +0000
treeherdermozilla-aurora@3a65ec0ec324 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, sledru
bugs959230
milestone29.0a2
Bug 959230 - Use DOMWindowCreated events to add payments listeners. r=mfinkle, a=sledru
mobile/android/components/PaymentsUI.js
--- a/mobile/android/components/PaymentsUI.js
+++ b/mobile/android/components/PaymentsUI.js
@@ -128,17 +128,17 @@ PaymentUI.prototype = {
     }
 
     // TODO: For now, known payment providers (BlueVia and Mozilla Market)
     // only accepts the JWT by GET, so we just add it to the URI.
     // https://github.com/mozilla-b2g/gaia/blob/master/apps/system/js/payment.js
     let tab = content.BrowserApp.addTab(aPaymentFlowInfo.uri + aPaymentFlowInfo.jwt);
 
     // Inject paymentSuccess and paymentFailed methods into the document after its loaded.
-    tab.browser.addEventListener("DOMContentLoaded", function loadPaymentShim() {
+    tab.browser.addEventListener("DOMWindowCreated", function loadPaymentShim() {
       let frame = tab.browser.contentDocument.defaultView;
       try {
         frame.wrappedJSObject.mozPaymentProvider = {
           __exposedProps__: {
             paymentSuccess: 'r',
             paymentFailed: 'r',
             mnc: 'r',
             mcc: 'r',
@@ -167,17 +167,17 @@ PaymentUI.prototype = {
           },
 
           paymentSuccess: paymentSuccess(aRequestId),
           paymentFailed: paymentFailed(aRequestId)
         };
       } catch (e) {
         _error(aRequestId, "ERROR_ADDING_METHODS");
       } finally {
-        tab.browser.removeEventListener("DOMContentLoaded", loadPaymentShim);
+        tab.browser.removeEventListener("DOMWindowCreated", loadPaymentShim);
       }
     }, true);
 
     // Store a reference to the tab so that we can close it when the payment succeeds or fails.
     paymentTabs[aRequestId] = tab;
     cancelTabCallbacks[aRequestId] = paymentCanceled(aRequestId);
 
     // Fail the payment if the tab is closed on its own