[dart-web] Remove dart:web_sql library.

The WebSQL standard was abandoned more than 10 years ago and is not
supported by many browsers.

The `dart:web_sql` library was marked as deprecated in Dart 2.14. This
CL makes the library inaccesible, removes support for `dart:web_sql` imports,
and removes the `Window.openDatabase` API. The old code for `dart:web_sql` is
still generated by the html generators. Removing that will be handled by a
separate change.

Closes https://github.com/dart-lang/sdk/issues/46316

Change-Id: I892107396b3b227b4f33344377585aa5e5328288
Bug: https://github.com/dart-lang/sdk/issues/46316
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216080
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Sigmund Cherem 2021-10-19 01:00:08 +00:00 committed by commit-bot@chromium.org
parent 5fff311900
commit 38b5a841de
25 changed files with 40 additions and 344 deletions

View file

@ -427,6 +427,19 @@
`callConstructor`, and `newObject` now support a generic type argument
to specify the return type.
#### `dart:web_sql`
- **Breaking Change** [#46316](https://github.com/dart-lang/sdk/issues/46316):
The WebSQL standard was abandoned more than 10
years ago and is not supported by many browsers. This release completely
deletes the `dart:web_sql` library.
#### `dart:html`
- **Breaking Change** [#46316](https://github.com/dart-lang/sdk/issues/46316):
Related to the removal of `dart:web_sql` (see above), the
`window.openDatabase` has been removed as well.
### Tools
#### Dart command line

View file

@ -224,9 +224,6 @@ class Uris {
/// The URI for 'dart:web_gl'.
static final Uri dart_web_gl = Uri(scheme: 'dart', path: 'web_gl');
/// The URI for 'dart:web_sql'.
static final Uri dart_web_sql = Uri(scheme: 'dart', path: 'web_sql');
/// The URI for 'dart:_js_helper'.
static final Uri dart__js_helper = Uri(scheme: 'dart', path: '_js_helper');

View file

@ -1359,7 +1359,6 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
type ??= findIn(Uris.dart_svg);
type ??= findIn(Uris.dart_web_audio);
type ??= findIn(Uris.dart_web_gl);
type ??= findIn(Uris.dart_web_sql);
type ??= findIn(Uris.dart_indexed_db);
type ??= findIn(Uris.dart_typed_data);
type ??= findIn(Uris.dart__rti);

View file

@ -36,7 +36,6 @@ const Iterable<String> _allowedDartSchemePaths = [
'_native_typed_data',
'web_audio',
'web_gl',
'web_sql'
];
List<Pattern> _allowedNativeTestPatterns = [
@ -246,7 +245,6 @@ const _requiredLibraries = <String, List<String>>{
'dart:svg',
'dart:web_audio',
'dart:web_gl',
'dart:web_sql',
],
'dart2js_server': [
'dart:_dart2js_runtime_metrics',

View file

@ -949,7 +949,6 @@ class KernelToElementMapImpl implements KernelToElementMap, IrToElementMap {
type ??= findIn(Uris.dart_svg);
type ??= findIn(Uris.dart_web_audio);
type ??= findIn(Uris.dart_web_gl);
type ??= findIn(Uris.dart_web_sql);
type ??= findIn(Uris.dart_indexed_db);
type ??= findIn(Uris.dart_typed_data);
type ??= findIn(Uris.dart__rti);

View file

@ -43,8 +43,7 @@ class JsInteropClass {
native:OverconstrainedError,
native:PositionError,
native:SensorErrorEvent,
native:SpeechRecognitionError,
native:SqlError]
native:SpeechRecognitionError]
*/
@JS()
external double method();

View file

@ -61,7 +61,6 @@ import 'package:js/js.dart';
native:PositionError,
native:SensorErrorEvent,
native:SpeechRecognitionError,
native:SqlError,
param:Function*]
*/
@JS()

View file

@ -68,7 +68,6 @@ import 'package:js/js.dart';
native:PositionError,
native:SensorErrorEvent,
native:SpeechRecognitionError,
native:SqlError,
param:void Function(String*,File*)*]
*/
@JS()

View file

@ -29,7 +29,7 @@ main() {
type=[inst:JSNull,inst:JSString,native:bool,native:int]
*/
testJSCall() => foreign.JS(
'int|bool|NativeUint8List|Rectangle|IdbFactory|SqlDatabase|TypedData|ContextAttributes',
'int|bool|NativeUint8List|Rectangle|IdbFactory|TypedData|ContextAttributes',
'#',
null);

View file

@ -71,7 +71,6 @@ class NativeTypeSet {
_addPendingExtensionTypes(sdk.getLibrary('dart:svg'));
_addPendingExtensionTypes(sdk.getLibrary('dart:web_audio'));
_addPendingExtensionTypes(sdk.getLibrary('dart:web_gl'));
_addPendingExtensionTypes(sdk.getLibrary('dart:web_sql'));
// For testing purposes only, we add extension types outside the Dart SDK.
// These are only allowed for native tests (see allowedNativeTest).

View file

@ -45,7 +45,6 @@ const sdkLibraryEnvironmentDefines = {
'dart.library.ui': 'false',
'dart.library.web_audio': 'true',
'dart.library.web_gl': 'true',
'dart.library.web_sql': 'true',
};
/// A kernel [Target] to configure the Dart Front End for dartdevc.
@ -114,7 +113,6 @@ class DevCompilerTarget extends Target {
'dart:svg',
'dart:web_audio',
'dart:web_gl',
'dart:web_sql'
];
// The libraries required to be indexed via CoreTypes.
@ -130,7 +128,6 @@ class DevCompilerTarget extends Target {
'dart:svg',
'dart:web_audio',
'dart:web_gl',
'dart:web_sql',
'dart:_foreign_helper',
'dart:_interceptors',
'dart:_js_helper',

View file

@ -40,7 +40,6 @@ final Map<String, List<String>> additionalRequiredClasses = {
'dart:svg': [],
'dart:web_audio': [],
'dart:web_gl': [],
'dart:web_sql': [],
'dart:_js_helper': [
'PrivateSymbol',
'LinkedMap',

View file

@ -139,10 +139,6 @@ const Map<String, LibraryInfo> libraries = const {
categories: "Client",
maturity: Maturity.WEB_STABLE,
platforms: DART2JS_PLATFORM),
"web_sql": const LibraryInfo("web_sql/dart2js/web_sql_dart2js.dart",
categories: "Client",
maturity: Maturity.WEB_STABLE,
platforms: DART2JS_PLATFORM),
"_internal": const LibraryInfo("internal/internal.dart",
categories: "",
documented: false,

View file

@ -31,7 +31,6 @@ import 'dart:web_audio' as web_audio;
import 'dart:web_audio' show AudioBuffer, AudioTrack, AudioTrackList;
import 'dart:web_gl' as gl;
import 'dart:web_gl' show RenderingContext, RenderingContext2;
import 'dart:web_sql';
import 'dart:_foreign_helper' show JS, JS_INTERCEPTOR_CONSTANT;
import 'dart:js_util' as js_util;
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
@ -9212,13 +9211,6 @@ class DataTransferItemList extends Interceptor {
// WARNING: Do not edit - generated code.
typedef void DatabaseCallback(SqlDatabase database);
// 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.
// WARNING: Do not edit - generated code.
typedef void DecodeErrorCallback(DomException error);
// 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
@ -32982,16 +32974,6 @@ class Window extends EventTarget
@JSName('moveTo')
void _moveTo(int x, int y) native;
@JSName('openDatabase')
/// *Deprecated.*
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Creates('SqlDatabase')
SqlDatabase _openDatabase(
String name, String version, String displayName, int estimatedSize,
[DatabaseCallback? creationCallback]) native;
void postMessage(/*any*/ message, String targetOrigin,
[List<Object>? transfer]) {
if (transfer != null) {
@ -33679,26 +33661,6 @@ class Window extends EventTarget
_moveTo(p.x.toInt(), p.y.toInt());
}
@JSName('openDatabase')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Creates('SqlDatabase')
@deprecated
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;
}
int get pageXOffset => JS<num>('num', '#.pageXOffset', this).round();
int get pageYOffset => JS<num>('num', '#.pageYOffset', this).round();

View file

@ -231,9 +231,6 @@
"web_gl": {
"uri": "web_gl/dart2js/web_gl_dart2js.dart"
},
"web_sql": {
"uri": "web_sql/dart2js/web_sql_dart2js.dart"
},
"_dart2js_runtime_metrics": {
"uri": "_internal/js_runtime/lib/dart2js_runtime_metrics.dart"
},
@ -476,10 +473,7 @@
},
"web_gl": {
"uri": "web_gl/dart2js/web_gl_dart2js.dart"
},
"web_sql": {
"uri": "web_sql/dart2js/web_sql_dart2js.dart"
}
}
}
}
}

View file

@ -229,9 +229,6 @@ dart2js:
web_gl:
uri: "web_gl/dart2js/web_gl_dart2js.dart"
web_sql:
uri: "web_sql/dart2js/web_sql_dart2js.dart"
_dart2js_runtime_metrics:
uri: "_internal/js_runtime/lib/dart2js_runtime_metrics.dart"
@ -470,6 +467,3 @@ dartdevc:
web_gl:
uri: "web_gl/dart2js/web_gl_dart2js.dart"
web_sql:
uri: "web_sql/dart2js/web_sql_dart2js.dart"

View file

@ -47,10 +47,6 @@ main() {
expectedResult,
const bool.fromEnvironment("dart.library.web_gl",
defaultValue: NOT_PRESENT));
Expect.equals(
expectedResult,
const bool.fromEnvironment("dart.library.web_sql",
defaultValue: NOT_PRESENT));
}
bool? hasIoSupport;

View file

@ -49,10 +49,6 @@ main() {
expectedResult,
const bool.fromEnvironment("dart.library.web_gl",
defaultValue: NOT_PRESENT));
Expect.equals(
expectedResult,
const bool.fromEnvironment("dart.library.web_sql",
defaultValue: NOT_PRESENT));
}
bool hasIoSupport;

View file

@ -0,0 +1,10 @@
// Copyright (c) 2021, 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.
import 'dart:web_sql';
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.URI_DOES_NOT_EXIST
// [cfe] Not found: 'dart:web_sql'
void main() {}

View file

@ -1,122 +0,0 @@
// Copyright (c) 2020, 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.
library WebDBTest;
import 'dart:async';
import 'dart:html';
import 'dart:web_sql';
import 'package:async_helper/async_minitest.dart';
Future<SqlResultSet> createTable(
SqlTransaction transaction, String tableName, String columnName) async {
return transaction.executeSql('CREATE TABLE $tableName ($columnName)', []);
}
Future<SqlResultSet> insertTable(SqlTransaction transaction, String tableName,
String columnName, value) async {
final sql = 'INSERT INTO $tableName ($columnName) VALUES (?)';
return transaction.executeSql(sql, [value]);
}
Future<SqlResultSet> queryTable(
SqlTransaction transaction, String tableName) async {
final sql = 'SELECT * FROM $tableName';
return transaction.executeSql(sql, []);
}
Future<SqlResultSet?> dropTable(SqlTransaction transaction, String tableName,
[bool ignoreFailure = false]) async {
try {
var result = await transaction.executeSql('DROP TABLE $tableName', []);
return result;
} catch (error) {
if (!ignoreFailure) throw error;
}
}
final tableName = 'test_table';
final columnName = 'test_data';
late SqlDatabase db;
late 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 {
await setup();
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");
} on DomException catch (error) {
expect(error.message,
"could not prepare statement (1 no such table: test_table)");
}
});
test('create', () async {
if (!SqlDatabase.supported) return;
expect(tx, isNotNull, reason: "Transaction not ready");
try {
SqlResultSet createResult =
await createTable(tx, tableName, columnName);
expect(createResult.insertId, 0);
} on DomException catch (error) {
expect(false, true, reason: "createTable failed - ${error.message}");
}
});
test('insert', () async {
if (!SqlDatabase.supported) return;
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);
} on DomException 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");
} on DomException 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);
});
});
}

View file

@ -0,0 +1,12 @@
// Copyright (c) 2021, 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.
// @dart = 2.9
import 'dart:web_sql';
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.URI_DOES_NOT_EXIST
// [cfe] Not found: 'dart:web_sql'
void main() {}

View file

@ -1,120 +0,0 @@
// @dart = 2.9
library WebDBTest;
import 'dart:async';
import 'dart:html';
import 'dart:web_sql';
import 'package:async_helper/async_minitest.dart';
Future<SqlResultSet> createTable(
SqlTransaction transaction, String tableName, String columnName) async {
return transaction.executeSql('CREATE TABLE $tableName ($columnName)', []);
}
Future<SqlResultSet> insertTable(SqlTransaction transaction, String tableName,
String columnName, value) async {
final sql = 'INSERT INTO $tableName ($columnName) VALUES (?)';
return transaction.executeSql(sql, [value]);
}
Future<SqlResultSet> queryTable(
SqlTransaction transaction, String tableName) async {
final sql = 'SELECT * FROM $tableName';
return transaction.executeSql(sql, []);
}
Future<SqlResultSet> dropTable(SqlTransaction transaction, String tableName,
[bool ignoreFailure = false]) async {
try {
var result = await transaction.executeSql('DROP TABLE $tableName', []);
return result;
} catch (error) {
if (!ignoreFailure) throw error;
}
}
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 {
await setup();
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)");
}
});
test('create', () async {
if (!SqlDatabase.supported) return;
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}");
}
});
test('insert', () async {
if (!SqlDatabase.supported) return;
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);
});
});
}

View file

@ -146,6 +146,7 @@ _removed_html_interfaces = [
'CSSValue',
'Counter',
'DOMFileSystemSync', # Workers
'DatabaseCallback', # WebSql was removed
'DatabaseSync', # Workers
'DirectoryEntrySync', # Workers
'DirectoryReaderSync', # Workers
@ -527,7 +528,6 @@ private_html_members = monitored.Set(
'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.pageXOffset',
@ -704,6 +704,7 @@ removed_html_members = monitored.Set(
'Window.createImageBitmap',
'Window.get:frames',
'Window.get:length',
'Window.openDatabase',
'Window.on:beforeUnload',
'Window.on:webkitTransitionEnd',
'Window.pagePopupController',

View file

@ -39,7 +39,6 @@ import 'dart:web_audio' as web_audio;
import 'dart:web_audio' show AudioBuffer, AudioTrack, AudioTrackList;
import 'dart:web_gl' as gl;
import 'dart:web_gl' show RenderingContext,RenderingContext2;
import 'dart:web_sql';
import 'dart:_js_helper' show
convertDartClosureToJS, Creates, JavaScriptIndexingBehavior,
JSName, Native, Returns,

View file

@ -222,26 +222,6 @@ $!MEMBERS
_moveTo(p.x.toInt(), p.y.toInt());
}
@JSName('openDatabase')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Creates('SqlDatabase')
@deprecated
SqlDatabase openDatabase(
String name, String version, String displayName, int estimatedSize,
[DatabaseCallback$NULLABLE 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;
}
int get pageXOffset => JS<num>('num', '#.pageXOffset', this).round();
int get pageYOffset => JS<num>('num', '#.pageYOffset', this).round();