diff --git a/js/ext/angular/test/service/ionicPlatform.unit.js b/js/ext/angular/test/service/ionicPlatform.unit.js index 93e0d3cf680..351e2c4b220 100644 --- a/js/ext/angular/test/service/ionicPlatform.unit.js +++ b/js/ext/angular/test/service/ionicPlatform.unit.js @@ -102,16 +102,16 @@ describe('Ionic Platform Service', function() { expect(ionic.Platform.isAndroid()).toEqual(true); }); - it('is Cordova', function() { - expect(ionic.Platform.isCordova()).toEqual(false); + it('is WebView', function() { + expect(ionic.Platform.isWebView()).toEqual(false); window.cordova = {}; - expect(ionic.Platform.isCordova()).toEqual(true); + expect(ionic.Platform.isWebView()).toEqual(true); delete window.cordova; window.PhoneGap = {}; - expect(ionic.Platform.isCordova()).toEqual(true); + expect(ionic.Platform.isWebView()).toEqual(true); delete window.phonegap; window.phonegap = {}; - expect(ionic.Platform.isCordova()).toEqual(true); + expect(ionic.Platform.isWebView()).toEqual(true); }); it('sets ios platforms', function() { @@ -121,10 +121,11 @@ describe('Ionic Platform Service', function() { ionic.Platform._checkPlatforms() - expect(ionic.Platform.platforms[0]).toEqual('cordova'); - expect(ionic.Platform.platforms[1]).toEqual('ios'); - expect(ionic.Platform.platforms[2]).toEqual('ios7'); - expect(ionic.Platform.platforms[3]).toEqual('ios7_0'); + expect(ionic.Platform.platforms[0]).toEqual('webview'); + expect(ionic.Platform.platforms[1]).toEqual('cordova'); + expect(ionic.Platform.platforms[2]).toEqual('ios'); + expect(ionic.Platform.platforms[3]).toEqual('ios7'); + expect(ionic.Platform.platforms[4]).toEqual('ios7_0'); }); it('sets android platforms', function() { @@ -134,21 +135,23 @@ describe('Ionic Platform Service', function() { ionic.Platform._checkPlatforms() - expect(ionic.Platform.platforms[0]).toEqual('cordova'); - expect(ionic.Platform.platforms[1]).toEqual('android'); - expect(ionic.Platform.platforms[2]).toEqual('android4'); - expect(ionic.Platform.platforms[3]).toEqual('android4_2'); + expect(ionic.Platform.platforms[0]).toEqual('webview'); + expect(ionic.Platform.platforms[1]).toEqual('cordova'); + expect(ionic.Platform.platforms[2]).toEqual('android'); + expect(ionic.Platform.platforms[3]).toEqual('android4'); + expect(ionic.Platform.platforms[4]).toEqual('android4_2'); }); - it('should only set the cordova', function() { + it('should only set the webview', function() { window.cordova = {}; ionic.Platform.setPlatform(''); ionic.Platform.setVersion(''); ionic.Platform._checkPlatforms() - expect(ionic.Platform.platforms.length).toEqual(1); - expect(ionic.Platform.platforms[0]).toEqual('cordova'); + expect(ionic.Platform.platforms.length).toEqual(2); + expect(ionic.Platform.platforms[0]).toEqual('webview'); + expect(ionic.Platform.platforms[1]).toEqual('cordova'); }); it('should not set any platform', function() { diff --git a/js/utils/platform.js b/js/utils/platform.js index 07316e4c9a9..129cdbc1a7e 100644 --- a/js/utils/platform.js +++ b/js/utils/platform.js @@ -79,7 +79,7 @@ */ device: function() { if(window.device) return window.device; - if(this.isCordova()) console.error('device plugin required'); + if(this.isWebView()) console.error('device plugin required'); return {}; }, @@ -87,7 +87,10 @@ this.platforms = []; this.grade = 'a'; - if(this.isCordova()) this.platforms.push('cordova'); + if(this.isWebView()) { + this.platforms.push('webview'); + this.platforms.push('cordova'); + } if(this.isIPad()) this.platforms.push('ipad'); var platform = this.platform(); @@ -114,10 +117,10 @@ /** * @ngdoc method - * @name ionic.Platform#isCordova - * @returns {boolean} Whether we are running on Cordova. + * @name ionic.Platform#isWebView + * @returns {boolean} Check if we are running within a WebView (such as Cordova). */ - isCordova: function() { + isWebView: function() { return !(!window.cordova && !window.PhoneGap && !window.phonegap); }, /** @@ -301,7 +304,7 @@ // setup listeners to know when the device is ready to go function onWindowLoad() { - if(ionic.Platform.isCordova()) { + if(ionic.Platform.isWebView()) { // the window and scripts are fully loaded, and a cordova/phonegap // object exists then let's listen for the deviceready document.addEventListener("deviceready", onPlatformReady, false);