Skip to content

Commit

Permalink
chore: remove windows leftovers
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed Aug 31, 2023
1 parent 06335fe commit 702d450
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 46 deletions.
29 changes: 6 additions & 23 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ exports.defineAutoTests = function () {
let SERVER_WITH_CREDENTIALS = '';

// flags
const isWindows = cordova.platformId === 'windows';
const isBrowser = cordova.platformId === 'browser';
const isWindowsPhone = isWindows && WinJS.Utilities.isPhone;
const isIE = isBrowser && navigator.userAgent.indexOf('Trident') >= 0;
const isIos = cordova.platformId === 'ios';
const isIot = cordova.platformId === 'android' && navigator.userAgent.indexOf('iot') >= 0;
Expand Down Expand Up @@ -488,11 +486,6 @@ exports.defineAutoTests = function () {
it(
'filetransfer.spec.7 should download a file using file:// (when hosted from file://)',
function (done) {

Check failure on line 488 in tests/tests.js

View workflow job for this annotation

GitHub Actions / Lint Test

Block must not be padded by blank lines
// for Windows platform it's ms-appdata:/// by default, not file://
if (isWindows) {
pending();
return;
}

const fileURL = window.location.protocol + '//' + window.location.pathname.replace(/ /g, '%20');
const specContext = this;
Expand Down Expand Up @@ -557,7 +550,7 @@ exports.defineAutoTests = function () {

specContext.transfer.download(fileURL, specContext.localFilePath, downloadWin, downloadFail);
},
isWindows ? LONG_TIMEOUT : DOWNLOAD_TIMEOUT
DOWNLOAD_TIMEOUT
);

it(
Expand Down Expand Up @@ -625,7 +618,7 @@ exports.defineAutoTests = function () {

specContext.transfer.download(fileURL, specContext.localFilePath, downloadWin, downloadFail);
},
isWindows ? LONG_TIMEOUT : DOWNLOAD_TIMEOUT
DOWNLOAD_TIMEOUT
);

it(
Expand Down Expand Up @@ -752,7 +745,7 @@ exports.defineAutoTests = function () {

this.transfer.download(fileURL, this.localFilePath, downloadWin, downloadFail);
},
isWindows ? LONG_TIMEOUT : DOWNLOAD_TIMEOUT
DOWNLOAD_TIMEOUT
);

it('filetransfer.spec.16 should handle bad file path', function (done) {
Expand Down Expand Up @@ -806,11 +799,7 @@ exports.defineAutoTests = function () {
expect(nativeURL).toBeTruthy();
expect(nativeURL).toEqual(jasmine.any(String));

if (isWindows) {
expect(nativeURL.substring(0, 14)).toBe('ms-appdata:///');
} else {
expect(nativeURL.substring(0, 7)).toBe('file://');
}
expect(nativeURL.substring(0, 7)).toBe('file://');

done();
};
Expand Down Expand Up @@ -1156,9 +1145,9 @@ exports.defineAutoTests = function () {
}, GRACE_TIME_DELTA);
};

// windows store and ios are too fast, win is called before we have a chance to abort
// ios is too fast, win is called before we have a chance to abort
// so let's get them busy - while not providing an extra load to the slow Android emulators
const arrayLength = (isWindows && !isWindowsPhone) || isIos ? 3000000 : isIot ? 150000 : 200000;
const arrayLength = isIos ? 3000000 : isIot ? 150000 : 200000;
writeFile(specContext.root, specContext.fileName, new Array(arrayLength).join('aborttest!'), fileWin, done);
},
UPLOAD_TIMEOUT
Expand Down Expand Up @@ -1746,9 +1735,6 @@ exports.defineAutoTests = function () {
it(
'filetransfer.spec.43 chunkedMode=true, multipart=false',
function (done) {
if (isWindows) {
pending();
}
testChunkedModeBase.call(this, true, false, done);
},
UPLOAD_TIMEOUT * 11
Expand All @@ -1765,9 +1751,6 @@ exports.defineAutoTests = function () {
it(
'filetransfer.spec.45 chunkedMode=true, multipart=true',
function (done) {
if (isWindows) {
pending();
}
testChunkedModeBase.call(this, true, true, done);
},
UPLOAD_TIMEOUT * 11
Expand Down
23 changes: 0 additions & 23 deletions www/FileTransfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,6 @@ function getBasicAuthHeader (urlString) {
return header;
}

function convertHeadersToArray (headers) {
const result = [];
for (const header in headers) {
if (Object.prototype.hasOwnProperty.call(headers, header)) {
const headerValue = headers[header];
result.push({
name: header,
value: headerValue.toString()
});
}
}
return result;
}

let idCounter = 0;

/**
Expand Down Expand Up @@ -139,11 +125,6 @@ FileTransfer.prototype.upload = function (filePath, server, successCallback, err
}
}

if (cordova.platformId === 'windowsphone') {
headers = headers && convertHeadersToArray(headers);
params = params && convertHeadersToArray(params);
}

const fail =
errorCallback &&
function (e) {
Expand Down Expand Up @@ -205,10 +186,6 @@ FileTransfer.prototype.download = function (source, target, successCallback, err
headers = options.headers || null;
}

if (cordova.platformId === 'windowsphone' && headers) {
headers = convertHeadersToArray(headers);
}

const win = function (result) {
if (typeof result.lengthComputable !== 'undefined') {
if (self.onprogress) {
Expand Down

0 comments on commit 702d450

Please sign in to comment.