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"
|
nodejs_version: "4"
|
||||||
matrix:
|
matrix:
|
||||||
- PLATFORM: windows-10-store
|
- PLATFORM: windows-10-store
|
||||||
|
JUST_BUILD: --justBuild
|
||||||
|
- PLATFORM: local\browser
|
||||||
install:
|
install:
|
||||||
- npm cache clean -f
|
- npm cache clean -f
|
||||||
- node --version
|
- node --version
|
||||||
@ -25,4 +26,4 @@ install:
|
|||||||
build: off
|
build: off
|
||||||
|
|
||||||
test_script:
|
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"
|
- TRAVIS_NODE_VERSION="4.2"
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
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
|
- env: PLATFORM=ios-9.3
|
||||||
os: osx
|
os: osx
|
||||||
osx_image: xcode7.3
|
osx_image: xcode7.3
|
||||||
|
12
README.md
12
README.md
@ -144,12 +144,12 @@ instance, or the system browser.
|
|||||||
- Amazon Fire OS
|
- Amazon Fire OS
|
||||||
- Android
|
- Android
|
||||||
- BlackBerry 10
|
- BlackBerry 10
|
||||||
|
- Browser
|
||||||
- Firefox OS
|
- Firefox OS
|
||||||
- iOS
|
- iOS
|
||||||
- OSX
|
- OSX
|
||||||
- Windows 8 and 8.1
|
- Windows 8 and 8.1
|
||||||
- Windows Phone 7 and 8
|
- Windows Phone 7 and 8
|
||||||
- Browser
|
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@ -323,10 +323,10 @@ function executeScriptCallBack(params) {
|
|||||||
|
|
||||||
- Amazon Fire OS
|
- Amazon Fire OS
|
||||||
- Android
|
- Android
|
||||||
|
- Browser
|
||||||
- iOS
|
- iOS
|
||||||
- Windows 8 and 8.1
|
- Windows 8 and 8.1
|
||||||
- Windows Phone 7 and 8
|
- Windows Phone 7 and 8
|
||||||
- Browser
|
|
||||||
|
|
||||||
### Browser Quirks
|
### Browser Quirks
|
||||||
|
|
||||||
@ -359,10 +359,10 @@ The function is passed an `InAppBrowserEvent` object.
|
|||||||
|
|
||||||
- Amazon Fire OS
|
- Amazon Fire OS
|
||||||
- Android
|
- Android
|
||||||
|
- Browser
|
||||||
- iOS
|
- iOS
|
||||||
- Windows 8 and 8.1
|
- Windows 8 and 8.1
|
||||||
- Windows Phone 7 and 8
|
- Windows Phone 7 and 8
|
||||||
- Browser
|
|
||||||
|
|
||||||
### Quick Example
|
### Quick Example
|
||||||
|
|
||||||
@ -383,11 +383,11 @@ The function is passed an `InAppBrowserEvent` object.
|
|||||||
|
|
||||||
- Amazon Fire OS
|
- Amazon Fire OS
|
||||||
- Android
|
- Android
|
||||||
|
- Browser
|
||||||
- Firefox OS
|
- Firefox OS
|
||||||
- iOS
|
- iOS
|
||||||
- Windows 8 and 8.1
|
- Windows 8 and 8.1
|
||||||
- Windows Phone 7 and 8
|
- Windows Phone 7 and 8
|
||||||
- Browser
|
|
||||||
|
|
||||||
### Quick Example
|
### Quick Example
|
||||||
|
|
||||||
@ -406,9 +406,9 @@ The function is passed an `InAppBrowserEvent` object.
|
|||||||
|
|
||||||
- Amazon Fire OS
|
- Amazon Fire OS
|
||||||
- Android
|
- Android
|
||||||
|
- Browser
|
||||||
- iOS
|
- iOS
|
||||||
- Windows 8 and 8.1
|
- Windows 8 and 8.1
|
||||||
- Browser
|
|
||||||
|
|
||||||
### Quick Example
|
### Quick Example
|
||||||
|
|
||||||
@ -460,9 +460,9 @@ The function is passed an `InAppBrowserEvent` object.
|
|||||||
|
|
||||||
- Amazon Fire OS
|
- Amazon Fire OS
|
||||||
- Android
|
- Android
|
||||||
|
- Browser
|
||||||
- iOS
|
- iOS
|
||||||
- Windows 8 and 8.1
|
- Windows 8 and 8.1
|
||||||
- Browser
|
|
||||||
|
|
||||||
### Quick Example
|
### Quick Example
|
||||||
|
|
||||||
|
@ -31,15 +31,30 @@ var browserWrap,
|
|||||||
|
|
||||||
function attachNavigationEvents(element, callback) {
|
function attachNavigationEvents(element, callback) {
|
||||||
var onError = function () {
|
var onError = function () {
|
||||||
|
try {
|
||||||
callback({ type: "loaderror", url: this.contentWindow.location.href}, {keepCallback: true});
|
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 () {
|
element.addEventListener("pageshow", function () {
|
||||||
|
try {
|
||||||
callback({ type: "loadstart", url: this.contentWindow.location.href}, {keepCallback: true});
|
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 () {
|
element.addEventListener("load", function () {
|
||||||
|
try {
|
||||||
callback({ type: "loadstop", url: this.contentWindow.location.href}, {keepCallback: true});
|
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);
|
element.addEventListener("error", onError);
|
||||||
@ -49,7 +64,8 @@ function attachNavigationEvents(element, callback) {
|
|||||||
var IAB = {
|
var IAB = {
|
||||||
close: function (win, lose) {
|
close: function (win, lose) {
|
||||||
if (browserWrap) {
|
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.parentNode.removeChild(browserWrap);
|
||||||
browserWrap = null;
|
browserWrap = null;
|
||||||
@ -68,6 +84,8 @@ var IAB = {
|
|||||||
target = args[1],
|
target = args[1],
|
||||||
features = args[2];
|
features = args[2];
|
||||||
|
|
||||||
|
IAB._win = win;
|
||||||
|
|
||||||
if (target === "_self" || !target) {
|
if (target === "_self" || !target) {
|
||||||
window.location = strUrl;
|
window.location = strUrl;
|
||||||
} else if (target === "_system") {
|
} else if (target === "_system") {
|
||||||
@ -88,7 +106,7 @@ var IAB = {
|
|||||||
|
|
||||||
browserWrap.onclick = function () {
|
browserWrap.onclick = function () {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
IAB.close(win);
|
IAB.close();
|
||||||
}, 0);
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -161,7 +179,7 @@ var IAB = {
|
|||||||
closeButton.innerHTML = "✖";
|
closeButton.innerHTML = "✖";
|
||||||
closeButton.addEventListener("click", function (e) {
|
closeButton.addEventListener("click", function (e) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
IAB.close(win);
|
IAB.close();
|
||||||
}, 0);
|
}, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
/* global MSApp */
|
/* global MSApp */
|
||||||
|
|
||||||
var cordova = require('cordova');
|
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;
|
window.alert = window.alert || navigator.notification.alert;
|
||||||
if (isWindows && navigator && navigator.notification && navigator.notification.alert) {
|
if (isWindows && navigator && navigator.notification && navigator.notification.alert) {
|
||||||
@ -80,7 +81,8 @@ exports.defineAutoTests = function () {
|
|||||||
function verifyEvent(evt, type) {
|
function verifyEvent(evt, type) {
|
||||||
expect(evt).toBeDefined();
|
expect(evt).toBeDefined();
|
||||||
expect(evt.type).toEqual(type);
|
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);
|
expect(evt.url).toEqual(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,7 +95,7 @@ exports.defineAutoTests = function () {
|
|||||||
expect(evt.message).toEqual(jasmine.any(String));
|
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');
|
iabInstance = cordova.InAppBrowser.open(url, '_blank');
|
||||||
|
|
||||||
expect(iabInstance).toBeDefined();
|
expect(iabInstance).toBeDefined();
|
||||||
@ -116,7 +118,11 @@ exports.defineAutoTests = function () {
|
|||||||
iabInstance.addEventListener('loadstart', onLoadStart);
|
iabInstance.addEventListener('loadstart', onLoadStart);
|
||||||
iabInstance.addEventListener('loadstop', function (evt) {
|
iabInstance.addEventListener('loadstop', function (evt) {
|
||||||
verifyEvent(evt, 'loadstop');
|
verifyEvent(evt, 'loadstop');
|
||||||
|
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();
|
expect(onLoadStart).toHaveBeenCalled();
|
||||||
|
}
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -132,6 +138,11 @@ exports.defineAutoTests = function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("inappbrowser.spec.6 should support loaderror event", function (done) {
|
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 = cordova.InAppBrowser.open(badUrl, '_blank');
|
||||||
iabInstance.addEventListener('loaderror', function (evt) {
|
iabInstance.addEventListener('loaderror', function (evt) {
|
||||||
verifyLoadErrorEvent(evt);
|
verifyLoadErrorEvent(evt);
|
||||||
|
Loading…
Reference in New Issue
Block a user