diff --git a/.eslintrc.yml b/.eslintrc.yml index b6f153dd5..781c36628 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -2,9 +2,15 @@ root: true extends: '@cordova/eslint-config/browser' globals: cordova: true + LocalFileSystem: true + FileError: true + DirectoryEntry: true + FileWriter: true + Flags: true + Metadata: true + FileSystem: true + resolveLocalFileSystemURL: true overrides: - files: [tests/**/*.js] extends: '@cordova/eslint-config/node-tests' - globals: - cordova: true diff --git a/tests/tests.js b/tests/tests.js index b442cd942..c12216d45 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -29,7 +29,7 @@ exports.defineAutoTests = function () { var isIE = isBrowser && (window.msIndexedDB); var isIndexedDBShim = isBrowser && !isChrome; // Firefox and IE for example - var isWindows = (cordova.platformId === 'windows' || cordova.platformId === 'windows8'); + var isWindows = cordova.platformId === 'windows'; /* eslint-enable no-undef */ var MEDIUM_TIMEOUT = 15000; @@ -417,7 +417,7 @@ exports.defineAutoTests = function () { }); it('file.spec.11 should error (NOT_FOUND_ERR) when resolving (non-existent) invalid file name', function (done) { - var fileName = cordova.platformId === 'windowsphone' ? root.toURL() + '/' + 'this.is.not.a.valid.file.txt' : joinURL(root.toURL(), 'this.is.not.a.valid.file.txt'); // eslint-disable-line no-undef + var fileName = joinURL(root.toURL(), 'this.is.not.a.valid.file.txt'); var fail = function (error) { expect(error).toBeDefined(); if (isChrome) { @@ -2453,7 +2453,7 @@ exports.defineAutoTests = function () { // FileReader describe('Read method', function () { it('file.spec.82 should error out on non-existent file', function (done) { - var fileName = cordova.platformId === 'windowsphone' ? root.toURL() + '/' + 'somefile.txt' : 'somefile.txt'; // eslint-disable-line no-undef + var fileName = 'somefile.txt'; var verifier = function (evt) { expect(evt).toBeDefined(); if (isChrome) { @@ -3440,8 +3440,6 @@ exports.defineAutoTests = function () { if (cordova.platformId === 'android') { // Starting from Cordova-Android 10.x, the app content is served from the https scheme pathExpect = 'https://'; - } else if (cordova.platformId === 'windowsphone') { - pathExpect = '//nativ'; } else if (isChrome) { pathExpect = 'filesystem:http://'; } @@ -3788,14 +3786,12 @@ exports.defineAutoTests = function () { it('file.spec.129 cordova.file.*Directory are set', function () { var expectedPaths = ['applicationDirectory', 'applicationStorageDirectory', 'dataDirectory', 'cacheDirectory']; /* eslint-disable no-undef */ - if (cordova.platformId === 'android' || cordova.platformId === 'amazon-fireos') { + if (cordova.platformId === 'android') { if (cordova.file.externalApplicationStorageDirectory !== null) { // https://issues.apache.org/jira/browse/CB-10411 // If external storage can't be mounted, the cordova.file.external* properties are null. expectedPaths.push('externalApplicationStorageDirectory', 'externalRootDirectory', 'externalCacheDirectory', 'externalDataDirectory'); } - } else if (cordova.platformId === 'blackberry10') { - expectedPaths.push('externalRootDirectory', 'sharedDirectory'); } else if (cordova.platformId === 'ios') { expectedPaths.push('syncedDataDirectory', 'documentsDirectory', 'tempDirectory'); } else if (cordova.platformId === 'osx') { @@ -3817,10 +3813,10 @@ exports.defineAutoTests = function () { var cdvfileApplicationDirectoryFsRootNameURL; if (cordova.platformId === 'android') { cdvfileApplicationDirectoryFsRootName = 'assets'; - cdvfileApplicationDirectoryFsRootNameURL = 'https://localhost/__cdvfile_' + cdvfileApplicationDirectoryFsRootName + '__/' + cdvfileApplicationDirectoryFsRootNameURL = 'https://localhost/__cdvfile_' + cdvfileApplicationDirectoryFsRootName + '__/'; } else if (cordova.platformId === 'ios') { cdvfileApplicationDirectoryFsRootName = 'bundle'; - cdvfileApplicationDirectoryFsRootNameURL = 'cdvfile://localhost/' + cdvfileApplicationDirectoryFsRootName + '/' + cdvfileApplicationDirectoryFsRootNameURL = 'cdvfile://localhost/' + cdvfileApplicationDirectoryFsRootName + '/'; } else { pending(); } @@ -4206,7 +4202,6 @@ exports.defineManualTests = function (contentEl, createActionButton) { ios: 'library,library-nosync,documents,documents-nosync,cache,bundle,root,private', osx: 'library,library-nosync,documents,documents-nosync,cache,bundle,root,private', android: 'files,files-external,documents,sdcard,cache,cache-external,assets,root', - 'amazon-fireos': 'files,files-external,documents,sdcard,cache,cache-external,root', windows: 'temporary,persistent' }; diff --git a/www/Entry.js b/www/Entry.js index a67be96fa..abe33d5df 100644 --- a/www/Entry.js +++ b/www/Entry.js @@ -117,7 +117,7 @@ Entry.prototype.moveTo = function (parent, newName, successCallback, errorCallba if (successCallback) { // create appropriate Entry object var newFSName = entry.filesystemName || (entry.filesystem && entry.filesystem.name); - var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' }); // eslint-disable-line no-undef + var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' }); var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL) : new (require('cordova-plugin-file.FileEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL); successCallback(result); } @@ -159,7 +159,7 @@ Entry.prototype.copyTo = function (parent, newName, successCallback, errorCallba if (successCallback) { // create appropriate Entry object var newFSName = entry.filesystemName || (entry.filesystem && entry.filesystem.name); - var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' }); // eslint-disable-line no-undef + var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' }); var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL) : new (require('cordova-plugin-file.FileEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL); successCallback(result); } diff --git a/www/FileReader.js b/www/FileReader.js index 121120618..bef959650 100644 --- a/www/FileReader.js +++ b/www/FileReader.js @@ -137,7 +137,7 @@ function readSuccessCallback (readType, encoding, offset, totalSize, accumulate, if (readType === 'readAsDataURL') { // Windows proxy does not support reading file slices as Data URLs // so read the whole file at once. - CHUNK_SIZE = cordova.platformId === 'windows' ? totalSize // eslint-disable-line no-undef + CHUNK_SIZE = cordova.platformId === 'windows' ? totalSize : ( // Calculate new chunk size for data URLs to be multiply of 3 // Otherwise concatenated base64 chunks won't be valid base64 data diff --git a/www/FileWriter.js b/www/FileWriter.js index c25eef658..0b942e54a 100644 --- a/www/FileWriter.js +++ b/www/FileWriter.js @@ -112,7 +112,7 @@ FileWriter.prototype.write = function (data, isPendingBlobReadResult) { var that = this; var supportsBinary = (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined'); /* eslint-disable no-undef */ - var isProxySupportBlobNatively = (cordova.platformId === 'windows8' || cordova.platformId === 'windows'); + var isProxySupportBlobNatively = cordova.platformId === 'windows'; var isBinary; // Check to see if the incoming data is a blob @@ -154,10 +154,6 @@ FileWriter.prototype.write = function (data, isPendingBlobReadResult) { // Mark data type for safer transport over the binary bridge isBinary = supportsBinary && (data instanceof ArrayBuffer); - if (isBinary && cordova.platformId === 'windowsphone') { // eslint-disable-line no-undef - // create a plain array, using the keys from the Uint8Array view so that we can serialize it - data = Array.apply(null, new Uint8Array(data)); - } // Throw an exception if we are already writing a file if (this.readyState === FileWriter.WRITING && !isPendingBlobReadResult) { diff --git a/www/android/Entry.js b/www/android/Entry.js index d9f180d7d..00555a439 100644 --- a/www/android/Entry.js +++ b/www/android/Entry.js @@ -20,14 +20,14 @@ */ module.exports = { - /** + /** * Return a URL that can be used to identify this entry. * Use a URL that can be used to as the src attribute of a