Skip to content

Commit

Permalink
spec with explicit check for Apple iOS userAgent
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher J. Brody committed Aug 14, 2018
1 parent 487b3c6 commit 954c148
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 27 deletions.
4 changes: 3 additions & 1 deletion spec/www/spec/basic-db-tx-sql-storage-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var DEFAULT_SIZE = 5000000; // max to avoid popup in safari/ios
var isWindows = /Windows /.test(navigator.userAgent); // Windows
var isAndroid = !isWindows && /Android/.test(navigator.userAgent);
var isMac = /Macintosh/.test(navigator.userAgent);
var isAppleMobileOS = /iPhone/.test(navigator.userAgent) ||
/iPad/.test(navigator.userAgent) || /iPod/.test(navigator.userAgent);

// NOTE: While in certain version branches there is no difference between
// the default Android implementation and implementation #2,
Expand Down Expand Up @@ -319,7 +321,7 @@ var mytests = function() {
// (WebKit) Web SQL:
// 1. [TBD] this is a native object that is NOT affected by the change
// on Android pre-5.x & iOS pre-11.x
if ((!isAndroid && !(/OS 1[1-9]/.test(navigator.userAgent))) ||
if ((isAppleMobileOS && !(/OS 1[1-9]/.test(navigator.userAgent))) ||
(/Android 4/.test(navigator.userAgent)) ||
(/Android 5.0/.test(navigator.userAgent)))
expect(temp1.data).toBe('test');
Expand Down
11 changes: 8 additions & 3 deletions spec/www/spec/browser-check-startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ var MYTIMEOUT = 12000;
var isWindows = /Windows /.test(navigator.userAgent); // Windows 8.1/Windows Phone 8.1/Windows 10
var isAndroid = !isWindows && /Android/.test(navigator.userAgent);
var isMac = /Macintosh/.test(navigator.userAgent);
var isAppleMobileOS = /iPhone/.test(navigator.userAgent) ||
/iPad/.test(navigator.userAgent) || /iPod/.test(navigator.userAgent);
// XXX FUTURE TBD RENAME to hasWKWebView
// (here and in actual test scripts):
var isWKWebView = isAppleMobileOS && !!window.webkit && !!window.webkit.messageHandlers;

window.hasBrowser = true;
// XXX FUTURE TODO rename to something like window.hasWebKitWebSQL here
// and in actual test scripts
window.hasWebKitBrowser = (!isWindows && !isMac && (isAndroid || !(window.webkit && window.webkit.messageHandlers)));
// XXX FUTURE TODO RENAME to window.hasWebKitWebSQL
// (here and in actual test scripts):
window.hasWebKitBrowser = isAndroid || (isAppleMobileOS && !isWKWebView);

describe('Check startup for navigator.userAgent: ' + navigator.userAgent, function() {
it('receives deviceready event', function(done) {
Expand Down
4 changes: 2 additions & 2 deletions spec/www/spec/db-open-close-delete-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ var mytests = function() {
}, MYTIMEOUT);

it(suiteName + 'Open database with u2028 & check internal database file name on Windows ONLY [KNOWN ISSUE on Cordova for Android/iOS/...]', function(done) {
if (!isWindows) pending('SKIP for Android/macOS/iOS due to KNOWN CORDOVA ISSUE');
if (isAndroid || isAppleMobileOS || isMac) pending('SKIP for Android/macOS/iOS due to KNOWN CORDOVA ISSUE');

var dbName = 'first\u2028second.db';

Expand Down Expand Up @@ -268,7 +268,7 @@ var mytests = function() {
}, MYTIMEOUT);

it(suiteName + 'Open database with u2029 & check internal database file name on Windows ONLY [KNOWN ISSUE on Cordova for Android/iOS/...]', function(done) {
if (!isWindows) pending('SKIP for Android/macOS/iOS due to KNOWN CORDOVA ISSUE');
if (isAndroid || isAppleMobileOS || isMac) pending('SKIP for Android/macOS/iOS due to KNOWN CORDOVA ISSUE');

var dbName = 'first\u2029second.db';

Expand Down
4 changes: 3 additions & 1 deletion spec/www/spec/db-sql-operations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ var MYTIMEOUT = 30000;
var isWindows = /Windows /.test(navigator.userAgent); // Windows
var isAndroid = !isWindows && /Android/.test(navigator.userAgent);
var isMac = /Macintosh/.test(navigator.userAgent);
var isWKWebView = !isWindows && !isAndroid && !isMac && !!window.webkit && !!window.webkit.messageHandlers;
var isAppleMobileOS = /iPhone/.test(navigator.userAgent) ||
/iPad/.test(navigator.userAgent) || /iPod/.test(navigator.userAgent);
var isWKWebView = isAppleMobileOS && !!window.webkit && !!window.webkit.messageHandlers;

// NOTE: While in certain version branches there is no difference between
// the default Android implementation and implementation #2,
Expand Down
7 changes: 5 additions & 2 deletions spec/www/spec/db-tx-sql-features-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ var DEFAULT_SIZE = 5000000; // max to avoid popup in safari/ios

var isWindows = /Windows /.test(navigator.userAgent); // Windows
var isAndroid = !isWindows && /Android/.test(navigator.userAgent);
var isMac = /Macintosh/.test(navigator.userAgent);
var isAppleMobileOS = /iPhone/.test(navigator.userAgent) ||
/iPad/.test(navigator.userAgent) || /iPod/.test(navigator.userAgent);

// NOTE: While in certain version branches there is no difference between
// the default Android implementation and implementation #2,
Expand Down Expand Up @@ -78,7 +81,7 @@ var mytests = function() {
/* THANKS to @calebeaires: */
it(suiteName + 'create virtual table using FTS3', function(done) {
if (isWebSql && isAndroid) pending('SKIP for Android Web SQL');
if (isWebSql && !isAndroid && (/OS 1[1-9]/.test(navigator.userAgent))) pending('SKIP (WebKit) Web SQL on iOS 11(+)');
if (isWebSql && isAppleMobileOS && (/OS 1[1-9]/.test(navigator.userAgent))) pending('SKIP (WebKit) Web SQL on iOS 11(+)');

var db = openDatabase('virtual-table-using-fts3.db', '1.0', 'Test', DEFAULT_SIZE);

Expand Down Expand Up @@ -319,7 +322,7 @@ var mytests = function() {
if (isWebSql) pending('SKIP for Web SQL (NOT IMPLEMENTED)');
if (isWindows) pending('NOT IMPLEMENTED for Windows');
if (isAndroid && !isWebSql) pending('SKIP for Android plugin'); // FUTURE TBD test with newer versions (android.database)
if (!(isAndroid || isWindows || isWP8)) pending('SKIP for iOS'); // NOT WORKING on any versions of iOS (plugin or Web SQL)
if (isAppleMobileOS || isMac) pending('SKIP for iOS/macOS'); // NOT WORKING on any versions of iOS/macOS (plugin or Web SQL)

var db = openDatabase('delete-limit-test.db', '1.0', 'Test', DEFAULT_SIZE);
expect(db).toBeDefined();
Expand Down
24 changes: 13 additions & 11 deletions spec/www/spec/db-tx-sql-select-value-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ var DEFAULT_SIZE = 5000000; // max to avoid popup in safari/ios
var isWindows = /Windows /.test(navigator.userAgent); // Windows
var isAndroid = !isWindows && /Android/.test(navigator.userAgent);
var isMac = /Macintosh/.test(navigator.userAgent);
var isWKWebView = !isWindows && !isAndroid && !isMac && !!window.webkit && !!window.webkit.messageHandlers;
var isAppleMobileOS = /iPhone/.test(navigator.userAgent) ||
/iPad/.test(navigator.userAgent) || /iPod/.test(navigator.userAgent);
var isWKWebView = isAppleMobileOS && !!window.webkit && !!window.webkit.messageHandlers;

// The following openDatabase settings are used for Plugin-implementation-2
// on Android:
Expand Down Expand Up @@ -1084,7 +1086,7 @@ var mytests = function() {

it(suiteName + "SELECT -ABS(?) with '9e999' (Infinity) parameter argument" +
((!isWebSql && isAndroid) ? ' [Android PLUGIN BROKEN: missing result]' : ''), function(done) {
if (!isWebSql && !isAndroid && !isWindows) pending('SKIP for iOS/macOS plugin due to CRASH');
if (!isWebSql && (isAppleMobileOS || isMac)) pending('KNOWN CRASH on iOS/macOS'); // XXX (litehelpers/Cordova-sqlite-storage#405)

var db = openDatabase('SELECT-ABS-minus-Infinite-parameter-results-test.db', '1.0', 'Test', DEFAULT_SIZE);

Expand Down Expand Up @@ -1183,7 +1185,7 @@ var mytests = function() {
// Android/iOS plugin issue
if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('');
else if (!isWebSql && !isWindows && !isMac)
else if (!isWebSql && (isAndroid || isAppleMobileOS))
expect(rs.rows.item(0).myresult).toBe(null);
else
expect(rs.rows.item(0).myresult).toBe('inf');
Expand Down Expand Up @@ -1216,7 +1218,7 @@ var mytests = function() {
// Android/iOS plugin issue
if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('');
else if (!isWebSql && !isWindows && !isMac)
else if (!isWebSql && (isAndroid || isAppleMobileOS))
expect(rs.rows.item(0).myresult).toBe(null);
else
expect(rs.rows.item(0).myresult).toBe('-INF');
Expand Down Expand Up @@ -1249,7 +1251,7 @@ var mytests = function() {
// Android/iOS plugin issue
if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('text');
else if (!isWebSql && !isWindows && !isMac)
else if (!isWebSql && (isAndroid || isAppleMobileOS))
expect(rs.rows.item(0).myresult).toBe('null');
else
expect(rs.rows.item(0).myresult).toBe('real');
Expand Down Expand Up @@ -1282,7 +1284,7 @@ var mytests = function() {
// Android/iOS plugin issue
if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('text');
else if (!isWebSql && !isWindows && !isMac)
else if (!isWebSql && (isAndroid || isAppleMobileOS))
expect(rs.rows.item(0).myresult).toBe('null');
else
expect(rs.rows.item(0).myresult).toBe('real');
Expand Down Expand Up @@ -1316,7 +1318,7 @@ var mytests = function() {
// Android/iOS plugin issue
if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('');
else if (!isWebSql && !isWindows)
else if (!isWebSql && (isAndroid || isAppleMobileOS || isMac))
expect(rs.rows.item(0).myresult).toBe(null);
else
expect(rs.rows.item(0).myresult).toBe(Infinity);
Expand Down Expand Up @@ -1347,10 +1349,10 @@ var mytests = function() {
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);

// Android/iOS plugin issue
// Android/iOS/macOS plugin issue
if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('');
else if (!isWebSql && !isWindows)
else if (!isWebSql && (isAndroid || isAppleMobileOS || isMac))
expect(rs.rows.item(0).myresult).toBe(null);
else
expect(rs.rows.item(0).myresult).toBe(-Infinity);
Expand Down Expand Up @@ -1828,8 +1830,8 @@ var mytests = function() {
expect(rs).toBeDefined();
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);
if (!isWebSql && !isAndroid && !isWindows)
expect(rs.rows.item(0).myresult).not.toBeDefined(); // not defined iOS/macOS
if (!isWebSql && (isAppleMobileOS || isMac))
expect(rs.rows.item(0).myresult).not.toBeDefined(); // not defined iOS/macOS plugin
else
expect(rs.rows.item(0).myresult).toBeDefined();
// TBD actual value (???)
Expand Down
9 changes: 6 additions & 3 deletions spec/www/spec/db-tx-string-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ var DEFAULT_SIZE = 5000000; // max to avoid popup in safari/ios

var isWindows = /Windows /.test(navigator.userAgent); // Windows (8.1)
var isAndroid = !isWindows && /Android/.test(navigator.userAgent);
var isMac = /Macintosh/.test(navigator.userAgent);
var isAppleMobileOS = /iPhone/.test(navigator.userAgent) ||
/iPad/.test(navigator.userAgent) || /iPod/.test(navigator.userAgent);

// NOTE: While in certain version branches there is no difference between
// the default Android implementation and implementation #2,
Expand Down Expand Up @@ -412,7 +415,7 @@ var mytests = function() {
if (isWebSql) expect('UNEXPECTED SUCCESS on (WebKit) Web SQL PLEASE UPDATE THIS TEST').toBe('--');
if (!isWebSql && isWindows) expect('UNEXPECTED SUCCESS on Windows PLUGIN PLEASE UPDATE THIS TEST').toBe('--');
if (!isWebSql && !isWindows && isAndroid && isImpl2) expect('UNEXPECTED SUCCESS on BUILTIN android.database PLEASE UPDATE THIS TEST').toBe('--');
if (!isWebSql && !isWindows && !isAndroid) expect('UNEXPECTED SUCCESS on iOS/macOS PLUGIN PLEASE UPDATE THIS TEST').toBe('--');
if (!isWebSql && (isAppleMobileOS || isMac)) expect('UNEXPECTED SUCCESS on iOS/macOS PLUGIN PLEASE UPDATE THIS TEST').toBe('--');
expect(rs2).toBeDefined();
expect(rs2.rows).toBeDefined();
expect(rs2.rows.length).toBe(1);
Expand Down Expand Up @@ -1496,7 +1499,7 @@ var mytests = function() {

it(suiteName + ' handles UNICODE \\u2028 line separator correctly [string test]', function (done) {
if (!isWebSql && !isWindows && isAndroid) pending('SKIP for Android plugin (cordova-android 6.x BUG: cordova/cordova-discuss#57)');
if (!isWebSql && !isWindows && !isAndroid) pending('SKIP for iOS/macOS plugin (Cordova BUG: CB-9435)');
if (!isWebSql && (isAppleMobileOS || isMac)) pending('SKIP for iOS/macOS plugin (Cordova BUG: CB-9435)');
if (isWebSql && !isWindows && isAndroid) pending('SKIP for Android Web SQL'); // TBD SKIP for Android Web for now

// NOTE: since the above test shows the UNICODE line separator (\u2028)
Expand Down Expand Up @@ -1590,7 +1593,7 @@ var mytests = function() {

it(suiteName + ' handles UNICODE \\u2029 paragraph separator correctly [string test]', function (done) {
if (!isWebSql && !isWindows && isAndroid) pending('SKIP for Android plugin (cordova-android 6.x BUG: cordova/cordova-discuss#57)');
if (!isWebSql && !isWindows && !isAndroid) pending('SKIP for iOS/macOS plugin (Cordova BUG: CB-9435)');
if (!isWebSql && (isAppleMobileOS || isMac)) pending('SKIP for iOS/macOS plugin (Cordova BUG: CB-9435)');

// NOTE: since the above test shows the UNICODE paragraph separator (\u2029)
// is seen by the sqlite implementation OK, it is now concluded that
Expand Down
4 changes: 3 additions & 1 deletion spec/www/spec/db-tx-value-bindings-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ var DEFAULT_SIZE = 5000000; // max to avoid popup in safari/ios
var isWindows = /Windows /.test(navigator.userAgent); // Windows 8.1/Windows Phone 8.1/Windows 10
var isAndroid = !isWindows && /Android/.test(navigator.userAgent);
var isMac = /Macintosh/.test(navigator.userAgent);
var isWKWebView = !isWindows && !isAndroid && !isMac && !!window.webkit && !!window.webkit.messageHandlers;
var isAppleMobileOS = /iPhone/.test(navigator.userAgent) ||
/iPad/.test(navigator.userAgent) || /iPod/.test(navigator.userAgent);
var isWKWebView = isAppleMobileOS && !!window.webkit && !!window.webkit.messageHandlers;

// NOTE: While in certain version branches there is no difference between
// the default Android implementation and implementation #2,
Expand Down
7 changes: 5 additions & 2 deletions spec/www/spec/regexp-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ var DEFAULT_SIZE = 5000000; // max to avoid popup in safari/ios
var isWindows = /Windows /.test(navigator.userAgent); // Windows
var isAndroidUA = /Android/.test(navigator.userAgent);
var isAndroid = (isAndroidUA && !isWindows);
var isMac = /Macintosh/.test(navigator.userAgent);
var isAppleMobileOS = /iPhone/.test(navigator.userAgent) ||
/iPad/.test(navigator.userAgent) || /iPod/.test(navigator.userAgent);

var scenarioList = [ isAndroid ? 'Plugin-implementation-default' : 'Plugin', 'HTML5', 'Plugin-implementation-2' ];

Expand Down Expand Up @@ -43,9 +46,9 @@ var mytests = function() {
if (isWindows) pending('NOT IMPLEMENTED for Windows (plugin)');
if (!isWebSql && !isWindows && isAndroid) pending('SKIP for Android plugin'); // TBD SKIP for Android plugin (for now)
if (isWebSql && /Android 4.[1-3]/.test(navigator.userAgent)) pending('SKIP for Android 4.1-4.3 (WebKit) Web SQL');
if (isWebSql && !isAndroid && !isWindows) pending('SKIP for iOS (WebKit) Web SQL');
if (isWebSql && isAppleMobileOS) pending('SKIP for iOS (WebKit) Web SQL');
// TBD REMOVE from version branches such as cordova-sqlite-ext:
if (!isWebSql && !isAndroid && !isWindows) pending('NOT IMPLEMENTED for iOS/macOS plugin');
if (!isWebSql && (isAppleMobileOS || isMac)) pending('NOT IMPLEMENTED on iOS/macOS plugin');

var db = openDatabase('simple-regexp-test.db', '1.0', 'test', DEFAULT_SIZE);

Expand Down
4 changes: 3 additions & 1 deletion spec/www/spec/sql-batch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ var MYTIMEOUT = 12000;
var isWindows = /Windows /.test(navigator.userAgent); // Windows (8.1)
var isAndroid = !isWindows && /Android/.test(navigator.userAgent);
var isMac = /Macintosh/.test(navigator.userAgent);
var isWKWebView = !isWindows && !isAndroid && !isMac && !!window.webkit && !!window.webkit.messageHandlers;
var isAppleMobileOS = /iPhone/.test(navigator.userAgent) ||
/iPad/.test(navigator.userAgent) || /iPod/.test(navigator.userAgent);
var isWKWebView = isAppleMobileOS && !!window.webkit && !!window.webkit.messageHandlers;

// NOTE: While in certain version branches there is no difference between
// the default Android implementation and implementation #2,
Expand Down

0 comments on commit 954c148

Please sign in to comment.