CB-13028 (CI) Browser builds on Travis and AppVeyor, Fixes tests on browser and browser implementation
This commit is contained in:
parent
32d867f8e4
commit
72ac4d7eca
@ -15,7 +15,8 @@ environment:
|
||||
nodejs_version: "4"
|
||||
matrix:
|
||||
- PLATFORM: windows-10-store
|
||||
|
||||
JUST_BUILD: --justBuild
|
||||
- PLATFORM: local\browser
|
||||
install:
|
||||
- npm cache clean -f
|
||||
- node --version
|
||||
@ -25,4 +26,4 @@ install:
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- cordova-paramedic --config pr\%PLATFORM% --plugin . --justBuild
|
||||
- cordova-paramedic --config pr\%PLATFORM% --plugin . %JUST_BUILD%
|
||||
|
16
.travis.yml
16
.travis.yml
@ -8,6 +8,22 @@ env:
|
||||
- TRAVIS_NODE_VERSION="4.2"
|
||||
matrix:
|
||||
include:
|
||||
- env: PLATFORM=browser-chrome
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-firefox
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-safari
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-edge
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=ios-9.3
|
||||
os: osx
|
||||
osx_image: xcode7.3
|
||||
|
12
README.md
12
README.md
@ -144,12 +144,12 @@ instance, or the system browser.
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- BlackBerry 10
|
||||
- Browser
|
||||
- Firefox OS
|
||||
- iOS
|
||||
- OSX
|
||||
- Windows 8 and 8.1
|
||||
- Windows Phone 7 and 8
|
||||
- Browser
|
||||
|
||||
### Example
|
||||
|
||||
@ -323,10 +323,10 @@ function executeScriptCallBack(params) {
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows 8 and 8.1
|
||||
- Windows Phone 7 and 8
|
||||
- Browser
|
||||
|
||||
### Browser Quirks
|
||||
|
||||
@ -359,10 +359,10 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows 8 and 8.1
|
||||
- Windows Phone 7 and 8
|
||||
- Browser
|
||||
|
||||
### Quick Example
|
||||
|
||||
@ -383,11 +383,11 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- Browser
|
||||
- Firefox OS
|
||||
- iOS
|
||||
- Windows 8 and 8.1
|
||||
- Windows Phone 7 and 8
|
||||
- Browser
|
||||
|
||||
### Quick Example
|
||||
|
||||
@ -406,9 +406,9 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows 8 and 8.1
|
||||
- Browser
|
||||
|
||||
### Quick Example
|
||||
|
||||
@ -460,9 +460,9 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows 8 and 8.1
|
||||
- Browser
|
||||
|
||||
### Quick Example
|
||||
|
||||
|
@ -31,15 +31,30 @@ var browserWrap,
|
||||
|
||||
function attachNavigationEvents(element, callback) {
|
||||
var onError = function () {
|
||||
callback({ type: "loaderror", url: this.contentWindow.location.href}, {keepCallback: true});
|
||||
try {
|
||||
callback({ type: "loaderror", url: this.contentWindow.location.href}, {keepCallback: true});
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: "loaderror", url: null}, {keepCallback: true});
|
||||
}
|
||||
};
|
||||
|
||||
element.addEventListener("pageshow", function () {
|
||||
callback({ type: "loadstart", url: this.contentWindow.location.href}, {keepCallback: true});
|
||||
try {
|
||||
callback({ type: "loadstart", url: this.contentWindow.location.href}, {keepCallback: true});
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: "loadstart", url: null}, {keepCallback: true});
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener("load", function () {
|
||||
callback({ type: "loadstop", url: this.contentWindow.location.href}, {keepCallback: true});
|
||||
try {
|
||||
callback({ type: "loadstop", url: this.contentWindow.location.href}, {keepCallback: true});
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: "loadstop", url: null}, {keepCallback: true});
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener("error", onError);
|
||||
@ -49,7 +64,8 @@ function attachNavigationEvents(element, callback) {
|
||||
var IAB = {
|
||||
close: function (win, lose) {
|
||||
if (browserWrap) {
|
||||
if (win) win({ type: "exit" });
|
||||
// use the "open" function callback so that the exit event is fired properly
|
||||
if (IAB._win) IAB._win({ type: "exit" });
|
||||
|
||||
browserWrap.parentNode.removeChild(browserWrap);
|
||||
browserWrap = null;
|
||||
@ -68,6 +84,8 @@ var IAB = {
|
||||
target = args[1],
|
||||
features = args[2];
|
||||
|
||||
IAB._win = win;
|
||||
|
||||
if (target === "_self" || !target) {
|
||||
window.location = strUrl;
|
||||
} else if (target === "_system") {
|
||||
@ -88,7 +106,7 @@ var IAB = {
|
||||
|
||||
browserWrap.onclick = function () {
|
||||
setTimeout(function () {
|
||||
IAB.close(win);
|
||||
IAB.close();
|
||||
}, 0);
|
||||
};
|
||||
|
||||
@ -161,7 +179,7 @@ var IAB = {
|
||||
closeButton.innerHTML = "✖";
|
||||
closeButton.addEventListener("click", function (e) {
|
||||
setTimeout(function () {
|
||||
IAB.close(win);
|
||||
IAB.close();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
|
@ -23,7 +23,8 @@
|
||||
/* global MSApp */
|
||||
|
||||
var cordova = require('cordova');
|
||||
var isWindows = cordova.platformId == 'windows';
|
||||
var isWindows = cordova.platformId === 'windows';
|
||||
var isBrowser = cordova.platformId === 'browser';
|
||||
|
||||
window.alert = window.alert || navigator.notification.alert;
|
||||
if (isWindows && navigator && navigator.notification && navigator.notification.alert) {
|
||||
@ -80,7 +81,8 @@ exports.defineAutoTests = function () {
|
||||
function verifyEvent(evt, type) {
|
||||
expect(evt).toBeDefined();
|
||||
expect(evt.type).toEqual(type);
|
||||
if (type !== 'exit') { // `exit` event does not have url field
|
||||
// `exit` event does not have url field, browser returns null url for CORS requests
|
||||
if (type !== 'exit' && !isBrowser) {
|
||||
expect(evt.url).toEqual(url);
|
||||
}
|
||||
}
|
||||
@ -93,7 +95,7 @@ exports.defineAutoTests = function () {
|
||||
expect(evt.message).toEqual(jasmine.any(String));
|
||||
}
|
||||
|
||||
it("inappbrowser.spec.3 should retun InAppBrowser instance with required methods", function () {
|
||||
it("inappbrowser.spec.3 should return InAppBrowser instance with required methods", function () {
|
||||
iabInstance = cordova.InAppBrowser.open(url, '_blank');
|
||||
|
||||
expect(iabInstance).toBeDefined();
|
||||
@ -116,7 +118,11 @@ exports.defineAutoTests = function () {
|
||||
iabInstance.addEventListener('loadstart', onLoadStart);
|
||||
iabInstance.addEventListener('loadstop', function (evt) {
|
||||
verifyEvent(evt, 'loadstop');
|
||||
expect(onLoadStart).toHaveBeenCalled();
|
||||
if (!isBrowser) {
|
||||
// according to documentation, "loadstart" event is not supported on browser
|
||||
// https://github.com/apache/cordova-plugin-inappbrowser#browser-quirks-1
|
||||
expect(onLoadStart).toHaveBeenCalled();
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -132,6 +138,11 @@ exports.defineAutoTests = function () {
|
||||
});
|
||||
|
||||
it("inappbrowser.spec.6 should support loaderror event", function (done) {
|
||||
if (isBrowser) {
|
||||
// according to documentation, "loaderror" event is not supported on browser
|
||||
// https://github.com/apache/cordova-plugin-inappbrowser#browser-quirks-1
|
||||
pending('Browser platform doesn\'t support loaderror event');
|
||||
}
|
||||
iabInstance = cordova.InAppBrowser.open(badUrl, '_blank');
|
||||
iabInstance.addEventListener('loaderror', function (evt) {
|
||||
verifyLoadErrorEvent(evt);
|
||||
|
Loading…
Reference in New Issue
Block a user