CB-7690 InAppBrowser loadstart/loadstop events issues
Subscribing to events before navigating
This commit is contained in:
parent
71b43d39a4
commit
3f80b0b59c
@ -120,14 +120,14 @@ var IAB = {
|
||||
popup.style.width = "100%";
|
||||
popup.style.height = "100%";
|
||||
|
||||
// start listening for navigation events
|
||||
attachNavigationEvents(popup, win);
|
||||
|
||||
if (isWebViewAvailable) {
|
||||
strUrl = strUrl.replace("ms-appx://", "ms-appx-web://");
|
||||
}
|
||||
popup.src = strUrl;
|
||||
|
||||
// start listening for navigation events
|
||||
attachNavigationEvents(popup, win);
|
||||
|
||||
browserWrap.appendChild(popup);
|
||||
}
|
||||
},
|
||||
|
@ -29,11 +29,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
function doOpen(url, target, params, numExpectedRedirects) {
|
||||
numExpectedRedirects = numExpectedRedirects || 0;
|
||||
console.log("Opening " + url);
|
||||
var iab = window.open(url, target, params);
|
||||
if (!iab) {
|
||||
alert('window.open returned ' + iab);
|
||||
return;
|
||||
}
|
||||
|
||||
var counts;
|
||||
var lastLoadStartURL;
|
||||
var wasReset = false;
|
||||
@ -48,6 +44,17 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
}
|
||||
reset();
|
||||
|
||||
var iab = window.open(url, target, params, {
|
||||
loaderror: logEvent,
|
||||
loadstart: logEvent,
|
||||
loadstop: logEvent,
|
||||
exit: logEvent
|
||||
});
|
||||
if (!iab) {
|
||||
alert('window.open returned ' + iab);
|
||||
return;
|
||||
}
|
||||
|
||||
function logEvent(e) {
|
||||
console.log('IAB event=' + JSON.stringify(e));
|
||||
counts[e.type]++;
|
||||
@ -85,10 +92,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
}
|
||||
}
|
||||
}
|
||||
iab.addEventListener('loaderror', logEvent);
|
||||
iab.addEventListener('loadstart', logEvent);
|
||||
iab.addEventListener('loadstop', logEvent);
|
||||
iab.addEventListener('exit', logEvent);
|
||||
|
||||
return iab;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ InAppBrowser.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function(strUrl, strWindowName, strWindowFeatures) {
|
||||
module.exports = function(strUrl, strWindowName, strWindowFeatures, callbacks) {
|
||||
// Don't catch calls that write to existing frames (e.g. named iframes).
|
||||
if (window.frames && window.frames[strWindowName]) {
|
||||
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
|
||||
@ -86,6 +86,12 @@ module.exports = function(strUrl, strWindowName, strWindowFeatures) {
|
||||
|
||||
strUrl = urlutil.makeAbsolute(strUrl);
|
||||
var iab = new InAppBrowser();
|
||||
|
||||
callbacks = callbacks || {};
|
||||
for (var callbackName in callbacks) {
|
||||
iab.addEventListener(callbackName, callbacks[callbackName]);
|
||||
}
|
||||
|
||||
var cb = function(eventname) {
|
||||
iab._eventHandler(eventname);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user