Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 93b5555

Browse files
marclavalvicb
authored andcommitted
feat(zone.js): support Android browser
1 parent 3b0ca3f commit 93b5555

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

lib/patch/property-descriptor.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,24 @@ function apply() {
1111
return;
1212
}
1313

14+
var supportsWebSocket = typeof WebSocket !== 'undefined';
1415
if (canPatchViaPropertyDescriptor()) {
1516
// for browsers that we can patch the descriptor: Chrome & Firefox
1617
var onEventNames = eventNames.map(function (property) {
1718
return 'on' + property;
1819
});
1920
utils.patchProperties(HTMLElement.prototype, onEventNames);
2021
utils.patchProperties(XMLHttpRequest.prototype);
21-
if (typeof WebSocket !== 'undefined') {
22+
if (supportsWebSocket) {
2223
utils.patchProperties(WebSocket.prototype);
2324
}
2425
} else {
25-
// Safari
26+
// Safari, Android browsers (Jelly Bean)
2627
patchViaCapturingAllTheEvents();
2728
utils.patchClass('XMLHttpRequest');
28-
webSocketPatch.apply();
29+
if (supportsWebSocket) {
30+
webSocketPatch.apply();
31+
}
2932
}
3033
}
3134

sauce.conf.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ module.exports = function (config) {
4949
browserName: 'internet explorer',
5050
platform: 'Windows 8.1',
5151
version: '11'
52+
},
53+
'SL_ANDROID4.3': {
54+
base: 'SauceLabs',
55+
browserName: 'android',
56+
platform: 'Linux',
57+
version: '4.3'
5258
}
5359
};
5460

test/patch/XMLHttpRequest.spec.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ describe('XMLHttpRequest', function () {
4848
var req = new XMLHttpRequest();
4949
req.open('get', '/', true);
5050
req.send();
51-
req.responseType = 'document';
52-
expect(req.responseType).toBe('document');
51+
try {
52+
req.responseType = 'document';
53+
expect(req.responseType).toBe('document');
54+
} catch (e) {
55+
//Android browser: using this setter throws, this should be preserved
56+
expect(e.message).toBe('INVALID_STATE_ERR: DOM Exception 11');
57+
}
5358
});
5459

5560
it('should preserve static constants', function() {

0 commit comments

Comments
 (0)