mirror of
https://gitee.com/shuto/cordova-plugin-network-information.git
synced 2025-01-18 21:52:48 +08:00
refactor: Removed all references of deprecated navigator.network (#117)
This commit is contained in:
parent
4387da910d
commit
ab7c85d2e7
@ -92,13 +92,10 @@ function checkConnection() {
|
|||||||
checkConnection();
|
checkConnection();
|
||||||
```
|
```
|
||||||
|
|
||||||
### API Change
|
### iOS Quirks
|
||||||
|
|
||||||
Until Cordova 2.3.0, the `Connection` object was accessed via
|
- <iOS7 can't detect the type of cellular network connection.
|
||||||
`navigator.network.connection`, after which it was changed to
|
- `navigator.connection.type` is set to `Connection.CELL` for all cellular data.
|
||||||
`navigator.connection` to match the W3C specification. It's still
|
|
||||||
available at its original location, but is deprecated and will
|
|
||||||
eventually be removed.
|
|
||||||
|
|
||||||
### Windows Quirks
|
### Windows Quirks
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ xmlns:android="http://schemas.android.com/apk/res/android"
|
|||||||
|
|
||||||
<js-module src="www/network.js" name="network">
|
<js-module src="www/network.js" name="network">
|
||||||
<clobbers target="navigator.connection" />
|
<clobbers target="navigator.connection" />
|
||||||
<clobbers target="navigator.network.connection" />
|
|
||||||
</js-module>
|
</js-module>
|
||||||
|
|
||||||
<js-module src="www/Connection.js" name="Connection">
|
<js-module src="www/Connection.js" name="Connection">
|
||||||
|
@ -216,7 +216,7 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private void updateConnectionInfo(NetworkInfo info) {
|
private void updateConnectionInfo(NetworkInfo info) {
|
||||||
// send update to javascript "navigator.network.connection"
|
// send update to javascript "navigator.connection"
|
||||||
// Jellybean sends its own info
|
// Jellybean sends its own info
|
||||||
JSONObject thisInfo = this.getConnectionInfo(info);
|
JSONObject thisInfo = this.getConnectionInfo(info);
|
||||||
if(!thisInfo.equals(lastInfo))
|
if(!thisInfo.equals(lastInfo))
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
exports.defineAutoTests = function () {
|
exports.defineAutoTests = function () {
|
||||||
describe('Network (navigator.connection)', function () {
|
describe('Network (navigator.connection)', function () {
|
||||||
it('network.spec.1 should exist', function () {
|
it('network.spec.1 should exist', function () {
|
||||||
expect(navigator.network && navigator.network.connection).toBeDefined();
|
|
||||||
expect(navigator.connection).toBeDefined();
|
expect(navigator.connection).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -43,10 +42,6 @@ exports.defineAutoTests = function () {
|
|||||||
expect(validValues[navigator.connection.type]).toBe(1);
|
expect(validValues[navigator.connection.type]).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('network.spec.3 should have the same value in deprecated and non-deprecated apis', function () {
|
|
||||||
expect(navigator.network.connection.type).toBe(navigator.connection.type);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('network.spec.4 should define constants for connection status', function () {
|
it('network.spec.4 should define constants for connection status', function () {
|
||||||
expect(Connection.UNKNOWN).toBe('unknown');
|
expect(Connection.UNKNOWN).toBe('unknown');
|
||||||
expect(Connection.ETHERNET).toBe('ethernet');
|
expect(Connection.ETHERNET).toBe('ethernet');
|
||||||
@ -72,7 +67,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
|
|
||||||
function printNetwork () {
|
function printNetwork () {
|
||||||
eventOutput('navigator.connection.type=' + navigator.connection.type);
|
eventOutput('navigator.connection.type=' + navigator.connection.type);
|
||||||
eventOutput('navigator.network.connection.type=' + navigator.network.connection.type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEvent (e) {
|
function onEvent (e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user