mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Updated PYTHON code to correctly generate web_sql and re-wrote/re-enabled async web_sql test.
Also, updated status files to correctly fix failures in FF, IE and removed other spurious status entries. R=alanknight@google.com,vsm@google.com Change-Id: Ic965103d892ff4d5d119712e3187e829f57cd022 Reviewed-on: https://dart-review.googlesource.com/31800 Reviewed-by: Terry Lucas <terry@google.com>
This commit is contained in:
parent
68e39ed6dc
commit
476b1e02a9
|
@ -30324,8 +30324,8 @@ class RtcPeerConnection extends EventTarget {
|
|||
var completer = new Completer();
|
||||
_setLocalDescription(description, () {
|
||||
completer.complete();
|
||||
}, (error) {
|
||||
completer.completeError(error);
|
||||
}, (exception) {
|
||||
completer.completeError(exception);
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
|
@ -30344,8 +30344,8 @@ class RtcPeerConnection extends EventTarget {
|
|||
var completer = new Completer();
|
||||
_setRemoteDescription(description, () {
|
||||
completer.complete();
|
||||
}, (error) {
|
||||
completer.completeError(error);
|
||||
}, (exception) {
|
||||
completer.completeError(exception);
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
|
@ -37965,6 +37965,8 @@ class Window extends EventTarget
|
|||
@DocsEditable()
|
||||
void _moveTo(int x, int y) native;
|
||||
|
||||
@JSName('openDatabase')
|
||||
|
||||
/// *Deprecated.*
|
||||
@DomName('Window.openDatabase')
|
||||
@DocsEditable()
|
||||
|
@ -37974,7 +37976,7 @@ class Window extends EventTarget
|
|||
// http://www.w3.org/TR/webdatabase/
|
||||
@Experimental() // deprecated
|
||||
@Creates('SqlDatabase')
|
||||
SqlDatabase openDatabase(
|
||||
SqlDatabase _openDatabase(
|
||||
String name, String version, String displayName, int estimatedSize,
|
||||
[DatabaseCallback creationCallback]) native;
|
||||
|
||||
|
@ -38921,6 +38923,28 @@ class Window extends EventTarget
|
|||
_moveTo(p.x, p.y);
|
||||
}
|
||||
|
||||
@JSName('openDatabase')
|
||||
@DomName('Window.openDatabase')
|
||||
@DocsEditable()
|
||||
@SupportedBrowser(SupportedBrowser.CHROME)
|
||||
@SupportedBrowser(SupportedBrowser.SAFARI)
|
||||
@Experimental()
|
||||
@Creates('SqlDatabase')
|
||||
SqlDatabase openDatabase(
|
||||
String name, String version, String displayName, int estimatedSize,
|
||||
[DatabaseCallback creationCallback]) {
|
||||
var db;
|
||||
if (creationCallback == null)
|
||||
db = _openDatabase(name, version, displayName, estimatedSize);
|
||||
else
|
||||
db = _openDatabase(
|
||||
name, version, displayName, estimatedSize, creationCallback);
|
||||
|
||||
applyExtension('Database', db);
|
||||
|
||||
return db;
|
||||
}
|
||||
|
||||
@DomName('Window.pageXOffset')
|
||||
@DocsEditable()
|
||||
int get pageXOffset => JS('num', '#.pageXOffset', this).round();
|
||||
|
|
|
@ -23,6 +23,7 @@ import 'dart:_interceptors' show Interceptor;
|
|||
|
||||
import 'dart:_js_helper'
|
||||
show
|
||||
applyExtension,
|
||||
convertDartClosureToJS,
|
||||
Creates,
|
||||
JSName,
|
||||
|
@ -128,6 +129,20 @@ class SqlDatabase extends Interceptor {
|
|||
void transaction(SqlTransactionCallback callback,
|
||||
[SqlTransactionErrorCallback errorCallback,
|
||||
VoidCallback successCallback]) native;
|
||||
|
||||
@JSName('transaction')
|
||||
@DomName('Database.transaction')
|
||||
@DocsEditable()
|
||||
Future<SqlTransaction> transaction_future() {
|
||||
var completer = new Completer<SqlTransaction>();
|
||||
transaction((value) {
|
||||
applyExtension('SQLTransaction', value);
|
||||
completer.complete(value);
|
||||
}, (error) {
|
||||
completer.completeError(error);
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
}
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
@ -304,10 +319,26 @@ class SqlTransaction extends Interceptor {
|
|||
throw new UnsupportedError("Not supported");
|
||||
}
|
||||
|
||||
@JSName('executeSql')
|
||||
@DomName('SQLTransaction.executeSql')
|
||||
@DocsEditable()
|
||||
void executeSql(String sqlStatement,
|
||||
void _executeSql(String sqlStatement,
|
||||
[List arguments,
|
||||
SqlStatementCallback callback,
|
||||
SqlStatementErrorCallback errorCallback]) native;
|
||||
|
||||
@JSName('executeSql')
|
||||
@DomName('SQLTransaction.executeSql')
|
||||
@DocsEditable()
|
||||
Future<SqlResultSet> executeSql(String sqlStatement, [List arguments]) {
|
||||
var completer = new Completer<SqlResultSet>();
|
||||
_executeSql(sqlStatement, arguments, (transaction, resultSet) {
|
||||
applyExtension('SQLResultSet', resultSet);
|
||||
applyExtension('SQLResultSetRowList', resultSet.rows);
|
||||
completer.complete(resultSet);
|
||||
}, (transaction, error) {
|
||||
completer.completeError(error);
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ js_typed_interop_default_arg_test/default_value: MissingCompileTimeError # Issue
|
|||
js_typed_interop_side_cast_exp_test: Pass, RuntimeError # Roll 50 failure
|
||||
mirrors_js_typed_interop_test: Pass, Slow
|
||||
svgelement_test/PathElement: Pass, RuntimeError # Roll 50 failure
|
||||
websql_test/functional: Pass, Timeout # Roll 50 failure
|
||||
wrapping_collections_test: SkipByDesign # Testing an issue that is only relevant to Dartium
|
||||
xhr_test/xhr: Pass, RuntimeError # Roll 50 failure
|
||||
|
||||
|
@ -116,7 +115,7 @@ transition_event_test/functional: Skip # Times out. Issue 22167
|
|||
two_scripts_htmltest: Skip # Times out on IE. Issue 21537
|
||||
webgl_1_test/functional: Fail # IE11 Feature support statuses - These results not yet noted in platform support annotations. All changes should be accompanied by platform support annotation changes.
|
||||
websocket_test/websocket: Fail # Issue 7875. Closed with "working as intended".
|
||||
websql_test/supported: Fail # IE11 Feature support statuses - These results not yet noted in platform support annotations. All changes should be accompanied by platform support annotation changes.
|
||||
websql_test: Fail # IE11 Feature support statuses - These results not yet noted in platform support annotations. All changes should be accompanied by platform support annotation changes.
|
||||
wheelevent_test: RuntimeError # Issue 23437
|
||||
worker_test/functional: Pass, Fail # Issues 20659.
|
||||
xhr_test/json: Fail # IE10 returns string, not JSON object
|
||||
|
@ -208,7 +207,7 @@ speechrecognition_test/supported: Fail # Firefox Feature support statuses - All
|
|||
text_event_test: Fail # Issue 17893
|
||||
touchevent_test/supported: Fail # Firefox Feature support statuses - All changes should be accompanied by platform support annotation changes.
|
||||
webgl_1_test: Pass, Fail # Issue 8219
|
||||
websql_test/supported: Fail # Firefox Feature support statuses - All changes should be accompanied by platform support annotation changes.
|
||||
websql_test: Fail # Firefox Feature support statuses - All changes should be accompanied by platform support annotation changes.
|
||||
xhr_test/xhr: Pass, Fail # Issue 11602
|
||||
|
||||
[ $compiler == dart2js && $browser ]
|
||||
|
|
|
@ -3,131 +3,126 @@ library WebDBTest;
|
|||
import 'dart:async';
|
||||
import 'dart:html';
|
||||
import 'dart:web_sql';
|
||||
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
|
||||
Future<SqlTransaction> transaction(SqlDatabase db) {
|
||||
final completer = new Completer<SqlTransaction>.sync();
|
||||
|
||||
db.transaction((SqlTransaction transaction) {
|
||||
completer.complete(transaction);
|
||||
}, (SqlError error) {
|
||||
completer.completeError(error);
|
||||
});
|
||||
|
||||
return completer.future;
|
||||
}
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
|
||||
Future<SqlResultSet> createTable(
|
||||
SqlTransaction transaction, String tableName, String columnName) {
|
||||
final completer = new Completer<SqlResultSet>.sync();
|
||||
|
||||
final sql = 'CREATE TABLE $tableName ($columnName)';
|
||||
transaction.executeSql(sql, [], (SqlTransaction tx, SqlResultSet rs) {
|
||||
completer.complete(rs);
|
||||
}, (SqlTransaction tx, SqlError error) {
|
||||
completer.completeError(error);
|
||||
});
|
||||
|
||||
return completer.future;
|
||||
SqlTransaction transaction, String tableName, String columnName) async {
|
||||
return transaction.executeSql('CREATE TABLE $tableName ($columnName)', []);
|
||||
}
|
||||
|
||||
Future<SqlResultSet> insert(
|
||||
SqlTransaction transaction, String tableName, String columnName, value) {
|
||||
final completer = new Completer<SqlResultSet>.sync();
|
||||
|
||||
Future<SqlResultSet> insertTable(SqlTransaction transaction, String tableName,
|
||||
String columnName, value) async {
|
||||
final sql = 'INSERT INTO $tableName ($columnName) VALUES (?)';
|
||||
transaction.executeSql(sql, [value], (SqlTransaction tx, SqlResultSet rs) {
|
||||
completer.complete(rs);
|
||||
}, (SqlTransaction tx, SqlError error) {
|
||||
completer.completeError(error);
|
||||
});
|
||||
|
||||
return completer.future;
|
||||
return transaction.executeSql(sql, [value]);
|
||||
}
|
||||
|
||||
Future<SqlResultSet> queryTable(SqlTransaction transaction, String tableName) {
|
||||
final completer = new Completer<SqlResultSet>.sync();
|
||||
|
||||
Future<SqlResultSet> queryTable(
|
||||
SqlTransaction transaction, String tableName) async {
|
||||
final sql = 'SELECT * FROM $tableName';
|
||||
transaction.executeSql(sql, [], (SqlTransaction tx, SqlResultSet rs) {
|
||||
completer.complete(rs);
|
||||
}, (SqlTransaction tx, SqlError error) {
|
||||
completer.completeError(error);
|
||||
});
|
||||
|
||||
return completer.future;
|
||||
return transaction.executeSql(sql, []);
|
||||
}
|
||||
|
||||
Future<SqlResultSet> dropTable(SqlTransaction transaction, String tableName,
|
||||
[bool ignoreFailure = false]) {
|
||||
final completer = new Completer<SqlResultSet>.sync();
|
||||
|
||||
final sql = 'DROP TABLE $tableName';
|
||||
transaction.executeSql(sql, [], (SqlTransaction tx, SqlResultSet rs) {
|
||||
completer.complete(rs);
|
||||
}, (SqlTransaction tx, SqlError error) {
|
||||
if (ignoreFailure) {
|
||||
completer.complete(null);
|
||||
} else {
|
||||
completer.completeError(error);
|
||||
}
|
||||
});
|
||||
|
||||
return completer.future;
|
||||
[bool ignoreFailure = false]) async {
|
||||
try {
|
||||
var result = await transaction.executeSql('DROP TABLE $tableName', []);
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (!ignoreFailure) throw error;
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
final tableName = 'test_table';
|
||||
final columnName = 'test_data';
|
||||
|
||||
SqlDatabase db;
|
||||
SqlTransaction tx;
|
||||
|
||||
Future setup() async {
|
||||
if (SqlDatabase.supported) {
|
||||
db = await window.openDatabase('test_db', '1.0', 'test_db', 1024 * 1024);
|
||||
expect(db, isNotNull, reason: 'Unable to open database');
|
||||
|
||||
tx = await db.transaction_future();
|
||||
expect(tx, isNotNull, reason: "Transaction not ready");
|
||||
}
|
||||
}
|
||||
|
||||
main() async {
|
||||
useHtmlIndividualConfiguration();
|
||||
|
||||
group('supported', () {
|
||||
await setup();
|
||||
|
||||
group('Database', () {
|
||||
test('supported', () {
|
||||
expect(SqlDatabase.supported, true);
|
||||
});
|
||||
});
|
||||
|
||||
group('functional', () {
|
||||
test('unsupported throws', () {
|
||||
var expectation = SqlDatabase.supported ? returnsNormally : throws;
|
||||
expect(() {
|
||||
window.openDatabase('test_db', '1.0', 'test_db', 1024 * 1024);
|
||||
}, expectation);
|
||||
});
|
||||
test('Web Database', () {
|
||||
// Skip if not supported.
|
||||
if (!SqlDatabase.supported) {
|
||||
return new Future.value();
|
||||
group('Database', () {
|
||||
test('Open/Transaction', () async {
|
||||
if (!SqlDatabase.supported) return;
|
||||
|
||||
expect(tx, isNotNull, reason: "Transaction not ready");
|
||||
|
||||
// Should not succeed table doesn't exist to be dropped.
|
||||
try {
|
||||
await dropTable(tx, tableName);
|
||||
expect(false, true, reason: "dropTable should fail");
|
||||
} catch (error) {
|
||||
expect(error.message,
|
||||
"could not prepare statement (1 no such table: test_table)");
|
||||
}
|
||||
});
|
||||
|
||||
final tableName = 'test_table';
|
||||
final columnName = 'test_data';
|
||||
test('create', () async {
|
||||
if (!SqlDatabase.supported) return;
|
||||
|
||||
final db = window.openDatabase('test_db', '1.0', 'test_db', 1024 * 1024);
|
||||
expect(tx, isNotNull, reason: "Transaction not ready");
|
||||
try {
|
||||
SqlResultSet createResult =
|
||||
await createTable(tx, tableName, columnName);
|
||||
expect(createResult.insertId, 0);
|
||||
} catch (error) {
|
||||
expect(false, true, reason: "createTable failed - ${error.message}");
|
||||
}
|
||||
});
|
||||
|
||||
expect(db, isNotNull, reason: 'Unable to open database');
|
||||
test('insert', () async {
|
||||
if (!SqlDatabase.supported) return;
|
||||
|
||||
var tx;
|
||||
return transaction(db).then((transaction) {
|
||||
tx = transaction;
|
||||
}).then((_) {
|
||||
// Attempt to clear out any tables which may be lurking from previous
|
||||
// runs.
|
||||
return dropTable(tx, tableName, true);
|
||||
}).then((_) {
|
||||
return createTable(tx, tableName, columnName);
|
||||
}).then((_) {
|
||||
return insert(tx, tableName, columnName, 'Some text data');
|
||||
}).then((_) {
|
||||
return queryTable(tx, tableName);
|
||||
}).then((resultSet) {
|
||||
expect(resultSet.rows.length, 1);
|
||||
var row = resultSet.rows.item(0);
|
||||
expect(row.containsKey(columnName), isTrue);
|
||||
expect(row[columnName], 'Some text data');
|
||||
expect(resultSet.rows[0], row);
|
||||
}).then((_) {
|
||||
return dropTable(tx, tableName);
|
||||
});
|
||||
expect(tx, isNotNull, reason: "Transaction not ready");
|
||||
try {
|
||||
SqlResultSet insertResult =
|
||||
await insertTable(tx, tableName, columnName, 'Some text data');
|
||||
expect(insertResult.insertId, 1);
|
||||
expect(insertResult.rowsAffected, 1);
|
||||
} catch (error) {
|
||||
expect(false, true, reason: "insert failed - ${error.message}");
|
||||
}
|
||||
});
|
||||
|
||||
test('query', () async {
|
||||
if (!SqlDatabase.supported) return;
|
||||
|
||||
expect(tx, isNotNull, reason: "Transaction not ready");
|
||||
try {
|
||||
SqlResultSet queryResult = await queryTable(tx, tableName);
|
||||
expect(queryResult.rows.length, 1);
|
||||
expect(queryResult.rows[0]['test_data'], "Some text data");
|
||||
} catch (error) {
|
||||
expect(false, true, reason: "queryTable failed - ${error.message}");
|
||||
}
|
||||
});
|
||||
|
||||
test('cleanup', () async {
|
||||
if (!SqlDatabase.supported) return;
|
||||
|
||||
expect(tx, isNotNull, reason: "Transaction not ready");
|
||||
await dropTable(tx, tableName, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -5,127 +5,124 @@ import 'dart:html';
|
|||
import 'dart:web_sql';
|
||||
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
Future<SqlTransaction> transaction(SqlDatabase db) {
|
||||
final completer = new Completer<SqlTransaction>.sync();
|
||||
|
||||
db.transaction((SqlTransaction transaction) {
|
||||
completer.complete(transaction);
|
||||
}, (SqlError error) {
|
||||
completer.completeError(error);
|
||||
});
|
||||
|
||||
return completer.future;
|
||||
}
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
|
||||
Future<SqlResultSet> createTable(
|
||||
SqlTransaction transaction, String tableName, String columnName) {
|
||||
final completer = new Completer<SqlResultSet>.sync();
|
||||
|
||||
final sql = 'CREATE TABLE $tableName ($columnName)';
|
||||
transaction.executeSql(sql, [], (SqlTransaction tx, SqlResultSet rs) {
|
||||
completer.complete(rs);
|
||||
}, (SqlTransaction tx, SqlError error) {
|
||||
completer.completeError(error);
|
||||
});
|
||||
|
||||
return completer.future;
|
||||
SqlTransaction transaction, String tableName, String columnName) async {
|
||||
return transaction.executeSql('CREATE TABLE $tableName ($columnName)', []);
|
||||
}
|
||||
|
||||
Future<SqlResultSet> insert(
|
||||
SqlTransaction transaction, String tableName, String columnName, value) {
|
||||
final completer = new Completer<SqlResultSet>.sync();
|
||||
|
||||
Future<SqlResultSet> insertTable(SqlTransaction transaction, String tableName,
|
||||
String columnName, value) async {
|
||||
final sql = 'INSERT INTO $tableName ($columnName) VALUES (?)';
|
||||
transaction.executeSql(sql, [value], (SqlTransaction tx, SqlResultSet rs) {
|
||||
completer.complete(rs);
|
||||
}, (SqlTransaction tx, SqlError error) {
|
||||
completer.completeError(error);
|
||||
});
|
||||
|
||||
return completer.future;
|
||||
return transaction.executeSql(sql, [value]);
|
||||
}
|
||||
|
||||
Future<SqlResultSet> queryTable(SqlTransaction transaction, String tableName) {
|
||||
final completer = new Completer<SqlResultSet>.sync();
|
||||
|
||||
Future<SqlResultSet> queryTable(
|
||||
SqlTransaction transaction, String tableName) async {
|
||||
final sql = 'SELECT * FROM $tableName';
|
||||
transaction.executeSql(sql, [], (SqlTransaction tx, SqlResultSet rs) {
|
||||
completer.complete(rs);
|
||||
}, (SqlTransaction tx, SqlError error) {
|
||||
completer.completeError(error);
|
||||
});
|
||||
|
||||
return completer.future;
|
||||
return transaction.executeSql(sql, []);
|
||||
}
|
||||
|
||||
Future<SqlResultSet> dropTable(SqlTransaction transaction, String tableName,
|
||||
[bool ignoreFailure = false]) {
|
||||
final completer = new Completer<SqlResultSet>.sync();
|
||||
|
||||
final sql = 'DROP TABLE $tableName';
|
||||
transaction.executeSql(sql, [], (SqlTransaction tx, SqlResultSet rs) {
|
||||
completer.complete(rs);
|
||||
}, (SqlTransaction tx, SqlError error) {
|
||||
if (ignoreFailure) {
|
||||
completer.complete(null);
|
||||
} else {
|
||||
completer.completeError(error);
|
||||
}
|
||||
});
|
||||
|
||||
return completer.future;
|
||||
[bool ignoreFailure = false]) async {
|
||||
try {
|
||||
var result = await transaction.executeSql('DROP TABLE $tableName', []);
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (!ignoreFailure) throw error;
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
group('supported', () {
|
||||
final tableName = 'test_table';
|
||||
final columnName = 'test_data';
|
||||
|
||||
SqlDatabase db;
|
||||
SqlTransaction tx;
|
||||
|
||||
Future setup() async {
|
||||
if (SqlDatabase.supported) {
|
||||
db = await window.openDatabase('test_db', '1.0', 'test_db', 1024 * 1024);
|
||||
expect(db, isNotNull, reason: 'Unable to open database');
|
||||
|
||||
tx = await db.transaction_future();
|
||||
expect(tx, isNotNull, reason: "Transaction not ready");
|
||||
}
|
||||
}
|
||||
|
||||
main() async {
|
||||
useHtmlConfiguration();
|
||||
|
||||
await setup();
|
||||
|
||||
group('Database', () {
|
||||
test('supported', () {
|
||||
expect(SqlDatabase.supported, true);
|
||||
});
|
||||
});
|
||||
|
||||
group('functional', () {
|
||||
test('unsupported throws', () {
|
||||
var expectation = SqlDatabase.supported ? returnsNormally : throws;
|
||||
expect(() {
|
||||
window.openDatabase('test_db', '1.0', 'test_db', 1024 * 1024);
|
||||
}, expectation);
|
||||
});
|
||||
test('Web Database', () {
|
||||
// Skip if not supported.
|
||||
if (!SqlDatabase.supported) {
|
||||
return new Future.value();
|
||||
group('Database', () {
|
||||
test('Open/Transaction', () async {
|
||||
if (!SqlDatabase.supported) return;
|
||||
|
||||
expect(tx, isNotNull, reason: "Transaction not ready");
|
||||
|
||||
// Should not succeed table doesn't exist to be dropped.
|
||||
try {
|
||||
await dropTable(tx, tableName);
|
||||
expect(false, true, reason: "dropTable should fail");
|
||||
} catch (error) {
|
||||
expect(error.message,
|
||||
"could not prepare statement (1 no such table: test_table)");
|
||||
}
|
||||
});
|
||||
|
||||
final tableName = 'test_table';
|
||||
final columnName = 'test_data';
|
||||
test('create', () async {
|
||||
if (!SqlDatabase.supported) return;
|
||||
|
||||
final db = window.openDatabase('test_db', '1.0', 'test_db', 1024 * 1024);
|
||||
expect(tx, isNotNull, reason: "Transaction not ready");
|
||||
try {
|
||||
SqlResultSet createResult =
|
||||
await createTable(tx, tableName, columnName);
|
||||
expect(createResult.insertId, 0);
|
||||
} catch (error) {
|
||||
expect(false, true, reason: "createTable failed - ${error.message}");
|
||||
}
|
||||
});
|
||||
|
||||
expect(db, isNotNull, reason: 'Unable to open database');
|
||||
test('insert', () async {
|
||||
if (!SqlDatabase.supported) return;
|
||||
|
||||
var tx;
|
||||
return transaction(db).then((transaction) {
|
||||
tx = transaction;
|
||||
}).then((_) {
|
||||
// Attempt to clear out any tables which may be lurking from previous
|
||||
// runs.
|
||||
return dropTable(tx, tableName, true);
|
||||
}).then((_) {
|
||||
return createTable(tx, tableName, columnName);
|
||||
}).then((_) {
|
||||
return insert(tx, tableName, columnName, 'Some text data');
|
||||
}).then((_) {
|
||||
return queryTable(tx, tableName);
|
||||
}).then((resultSet) {
|
||||
expect(resultSet.rows.length, 1);
|
||||
var row = resultSet.rows.item(0);
|
||||
expect(row.containsKey(columnName), isTrue);
|
||||
expect(row[columnName], 'Some text data');
|
||||
expect(resultSet.rows[0], row);
|
||||
}).then((_) {
|
||||
return dropTable(tx, tableName);
|
||||
});
|
||||
expect(tx, isNotNull, reason: "Transaction not ready");
|
||||
try {
|
||||
SqlResultSet insertResult =
|
||||
await insertTable(tx, tableName, columnName, 'Some text data');
|
||||
expect(insertResult.insertId, 1);
|
||||
expect(insertResult.rowsAffected, 1);
|
||||
} catch (error) {
|
||||
expect(false, true, reason: "insert failed - ${error.message}");
|
||||
}
|
||||
});
|
||||
|
||||
test('query', () async {
|
||||
if (!SqlDatabase.supported) return;
|
||||
|
||||
expect(tx, isNotNull, reason: "Transaction not ready");
|
||||
try {
|
||||
SqlResultSet queryResult = await queryTable(tx, tableName);
|
||||
expect(queryResult.rows.length, 1);
|
||||
expect(queryResult.rows[0]['test_data'], "Some text data");
|
||||
} catch (error) {
|
||||
expect(false, true, reason: "queryTable failed - ${error.message}");
|
||||
}
|
||||
});
|
||||
|
||||
test('cleanup', () async {
|
||||
if (!SqlDatabase.supported) return;
|
||||
|
||||
expect(tx, isNotNull, reason: "Transaction not ready");
|
||||
await dropTable(tx, tableName, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ html/js_typed_interop_default_arg_test/default_value: MissingCompileTimeError #
|
|||
html/js_typed_interop_side_cast_exp_test: Pass, RuntimeError # Roll 50 failure
|
||||
html/mirrors_js_typed_interop_test: Pass, Slow
|
||||
html/svgelement_test/PathElement: Pass, RuntimeError # Roll 50 failure
|
||||
html/websql_test: Pass, Timeout # Roll 50 failure
|
||||
html/wrapping_collections_test: SkipByDesign # Testing an issue that is only relevant to Dartium
|
||||
html/xhr_test/xhr: Pass, RuntimeError # Roll 50 failure
|
||||
isolate/browser/issue_12474_test: CompileTimeError # Issue 22529
|
||||
|
|
|
@ -29,7 +29,6 @@ html/no_linked_scripts_htmltest: Skip # Issue 29919
|
|||
html/scripts_htmltest: Skip # Issue 29919
|
||||
html/transferables_test: CompileTimeError # Issue 30975
|
||||
html/two_scripts_htmltest: Skip # Issue 29919
|
||||
html/websql_test: Pass, RuntimeError # Issue 31036
|
||||
isolate/*: SkipByDesign # No support for dart:isolate in dart4web (http://dartbug.com/30538)
|
||||
js/null_test: RuntimeError # Issue 30652
|
||||
math/double_pow_test: RuntimeError # Issue 29922
|
||||
|
|
|
@ -672,12 +672,51 @@ class HtmlDartGenerator(object):
|
|||
callback_info = GetCallbackInfo(
|
||||
self._database.GetInterface(info.callback_args[0].type_id))
|
||||
|
||||
# If more than one callback then the second argument is the error callback.
|
||||
# Some error callbacks have 2 args (e.g., executeSql) where the second arg
|
||||
# is the error - this is the argument we want.
|
||||
error_callback = ""
|
||||
if len(info.callback_args) > 1:
|
||||
error_callback_info = GetCallbackInfo(
|
||||
self._database.GetInterface(info.callback_args[1].type_id))
|
||||
error_callbackNames = []
|
||||
for paramInfo in error_callback_info.param_infos:
|
||||
error_callbackNames.append(paramInfo.name)
|
||||
errorCallbackVariables = ", ".join(error_callbackNames)
|
||||
errorName = error_callback_info.param_infos[-1].name
|
||||
error_callback = (',\n %s(%s) { completer.completeError(%s); }' %
|
||||
(('%s : ' % info.callback_args[1].name
|
||||
if info.requires_named_arguments and
|
||||
info.callback_args[1].is_optional else ''),
|
||||
errorCallbackVariables, errorName))
|
||||
|
||||
extensions = GetDDC_Extension(self._interface, info.declared_name)
|
||||
if extensions:
|
||||
ddc_extensions = "\n".join(extensions);
|
||||
else:
|
||||
ddc_extensions = ''
|
||||
|
||||
# Some callbacks have more than one parameters. If so use all of
|
||||
# those parameters. However, if more than one argument use the
|
||||
# type of the last argument to be returned e.g., executeSql the callback
|
||||
# is (transaction, resultSet) and only the resultSet is returned SqlResultSet.
|
||||
callbackArgsLen = len(callback_info.param_infos)
|
||||
future_generic = ''
|
||||
callbackVariables = ''
|
||||
completerVariable = ''
|
||||
if callbackArgsLen == 1:
|
||||
callbackVariables = 'value'
|
||||
completerVariable = callbackVariables
|
||||
if callback_info.param_infos[0].type_id:
|
||||
future_generic = '<%s>' % self._DartType(callback_info.param_infos[0].type_id)
|
||||
elif callbackArgsLen > 1:
|
||||
callbackNames = []
|
||||
for paramInfo in callback_info.param_infos:
|
||||
callbackNames.append(paramInfo.name)
|
||||
callbackVariables = ",".join(callbackNames)
|
||||
completerVariable = callbackNames[-1]
|
||||
future_generic = '<%s>' % self._DartType(callback_info.param_infos[-1].type_id)
|
||||
|
||||
param_list = info.ParametersAsArgumentList()
|
||||
metadata = ''
|
||||
if '_RenamingAnnotation' in dir(self):
|
||||
|
@ -690,7 +729,7 @@ class HtmlDartGenerator(object):
|
|||
' $ORIGINAL_FUNCTION($PARAMS_LIST\n'
|
||||
' $NAMED_PARAM($VARIABLE_NAME) { '
|
||||
'$DDC_EXTENSION\n'
|
||||
'completer.complete($VARIABLE_NAME); }'
|
||||
'completer.complete($COMPLETER_NAME); }'
|
||||
'$ERROR_CALLBACK);\n'
|
||||
' return completer.future;\n'
|
||||
' }\n',
|
||||
|
@ -704,17 +743,12 @@ class HtmlDartGenerator(object):
|
|||
NAMED_PARAM=('%s : ' % info.callback_args[0].name
|
||||
if info.requires_named_arguments and
|
||||
info.callback_args[0].is_optional else ''),
|
||||
VARIABLE_NAME= '' if len(callback_info.param_infos) == 0 else 'value',
|
||||
VARIABLE_NAME=callbackVariables,
|
||||
COMPLETER_NAME=completerVariable,
|
||||
DDC_EXTENSION=ddc_extensions,
|
||||
ERROR_CALLBACK=('' if len(info.callback_args) == 1 else
|
||||
(',\n %s(error) { completer.completeError(error); }' %
|
||||
('%s : ' % info.callback_args[1].name
|
||||
if info.requires_named_arguments and
|
||||
info.callback_args[1].is_optional else ''))),
|
||||
FUTURE_GENERIC = ('' if len(callback_info.param_infos) == 0 or
|
||||
not callback_info.param_infos[0].type_id else
|
||||
'<%s>' % self._DartType(callback_info.param_infos[0].type_id)),
|
||||
ORIGINAL_FUNCTION = html_name)
|
||||
ERROR_CALLBACK=error_callback,
|
||||
FUTURE_GENERIC=future_generic,
|
||||
ORIGINAL_FUNCTION=html_name)
|
||||
|
||||
def EmitHelpers(self, base_class):
|
||||
if not self._members_emitter:
|
||||
|
|
|
@ -190,6 +190,7 @@ convert_to_future_members = monitored.Set(
|
|||
'Notification.requestPermission',
|
||||
'RTCPeerConnection.setLocalDescription',
|
||||
'RTCPeerConnection.setRemoteDescription',
|
||||
'SQLTransaction.executeSql',
|
||||
'StorageInfo.requestQuota',
|
||||
'StorageQuota.requestQuota',
|
||||
'Window.webkitRequestFileSystem',
|
||||
|
@ -213,6 +214,12 @@ ddc_extensions = monitored.Dict('ddcextensions.ddc_extensions', {
|
|||
'applyExtension(\'Blob\', value);'
|
||||
]
|
||||
},
|
||||
'SQLTransaction': {
|
||||
'executeSql': [
|
||||
'applyExtension(\'SQLResultSet\', resultSet);'
|
||||
'applyExtension(\'SQLResultSetRowList\', resultSet.rows);'
|
||||
],
|
||||
},
|
||||
'Window': {
|
||||
'webkitRequestFileSystem':[
|
||||
'applyExtension(\'DOMFileSystem\', value);',
|
||||
|
@ -447,12 +454,13 @@ private_html_members = monitored.Set('htmlrenamer.private_html_members', [
|
|||
'Window.getComputedStyle',
|
||||
'Window.clearInterval',
|
||||
'Window.clearTimeout',
|
||||
'Window.openDatabase',
|
||||
# TODO(tll): These have been converted from int to double in Chrome 39 for
|
||||
# subpixel precision. Special case for backward compatibility.
|
||||
'Window.scrollX',
|
||||
'Window.scrollY',
|
||||
'Window.pageXOffset',
|
||||
'Window.pageYOffset',
|
||||
'Window.scrollX',
|
||||
'Window.scrollY',
|
||||
|
||||
'WindowTimers.clearInterval',
|
||||
'WindowTimers.clearTimeout',
|
||||
|
|
|
@ -19,8 +19,8 @@ import 'dart:collection' hide LinkedList, LinkedListEntry;
|
|||
import 'dart:_internal' show FixedLengthListMixin;
|
||||
import 'dart:html';
|
||||
import 'dart:html_common';
|
||||
import 'dart:_js_helper' show convertDartClosureToJS, Creates, JSName, Native,
|
||||
JavaScriptIndexingBehavior;
|
||||
import 'dart:_js_helper' show applyExtension, convertDartClosureToJS, Creates,
|
||||
JSName, Native, JavaScriptIndexingBehavior;
|
||||
import 'dart:_foreign_helper' show JS;
|
||||
import 'dart:_interceptors' show Interceptor;
|
||||
|
||||
|
|
25
tools/dom/templates/html/impl/impl_Database.darttemplate
Normal file
25
tools/dom/templates/html/impl/impl_Database.darttemplate
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of $LIBRARYNAME;
|
||||
|
||||
@DocsEditable()
|
||||
$(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
|
||||
$!MEMBERS
|
||||
|
||||
@JSName('transaction')
|
||||
@DomName('Database.transaction')
|
||||
@DocsEditable()
|
||||
Future<SqlTransaction> transaction_future() {
|
||||
var completer = new Completer<SqlTransaction>();
|
||||
transaction((value) {
|
||||
applyExtension('SQLTransaction', value);
|
||||
completer.complete(value);
|
||||
}, (error) {
|
||||
completer.completeError(error);
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
}
|
|
@ -227,6 +227,28 @@ $!MEMBERS
|
|||
_moveTo(p.x, p.y);
|
||||
}
|
||||
|
||||
@JSName('openDatabase')
|
||||
@DomName('Window.openDatabase')
|
||||
@DocsEditable()
|
||||
@SupportedBrowser(SupportedBrowser.CHROME)
|
||||
@SupportedBrowser(SupportedBrowser.SAFARI)
|
||||
@Experimental()
|
||||
@Creates('SqlDatabase')
|
||||
SqlDatabase openDatabase(
|
||||
String name, String version, String displayName, int estimatedSize,
|
||||
[DatabaseCallback creationCallback]) {
|
||||
var db;
|
||||
if (creationCallback == null)
|
||||
db = _openDatabase(name, version, displayName, estimatedSize);
|
||||
else
|
||||
db = _openDatabase(
|
||||
name, version, displayName, estimatedSize, creationCallback);
|
||||
|
||||
applyExtension('Database', db);
|
||||
|
||||
return db;
|
||||
}
|
||||
|
||||
@DomName('Window.pageXOffset')
|
||||
@DocsEditable()
|
||||
int get pageXOffset => JS('num', '#.pageXOffset', this).round();
|
||||
|
|
Loading…
Reference in a new issue