mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:30:32 +00:00
[dart:html] Migrate tests that need changes to NNBD
Remaining tests that don't belong to any real test suite, but need some changes beyond just null asserts to be migrated. Change-Id: I91c0cb02eb72ada572a10c567b5d8bac596b16a4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142445 Reviewed-by: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
parent
156e1c84c8
commit
5b2482004b
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
library canvas_rendering_context_2d_test;
|
||||
|
||||
import 'dart:html';
|
||||
|
@ -38,8 +36,8 @@ main() {
|
|||
// The box does not draw after `width` pixels.
|
||||
// Check -2 rather than -1 because this seems
|
||||
// to run into a rounding error on Mac bots.
|
||||
expectPixelFilled(x + width - 2, y);
|
||||
expectPixelUnfilled(x + width + 1, y);
|
||||
expectPixelFilled((x + width - 2).toInt(), y);
|
||||
expectPixelUnfilled((x + width + 1).toInt(), y);
|
||||
});
|
||||
|
||||
test('with maxWidth null', () {
|
||||
|
@ -61,8 +59,8 @@ main() {
|
|||
// The box does not draw after `width` pixels.
|
||||
// Check -2 rather than -1 because this seems
|
||||
// to run into a rounding error on Mac bots.
|
||||
expectPixelFilled(x + width - 2, y);
|
||||
expectPixelUnfilled(x + width + 1, y);
|
||||
expectPixelFilled((x + width - 2).toInt(), y);
|
||||
expectPixelUnfilled((x + width + 1).toInt(), y);
|
||||
});
|
||||
|
||||
test('with maxWidth defined', () {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
@ -15,13 +13,13 @@ main() {
|
|||
predicate((x) => x is AnchorElement, 'is an AnchorElement');
|
||||
|
||||
List<String> _nodeStrings(Iterable<Node> input) {
|
||||
var out = new List<String>();
|
||||
List<String> out = [];
|
||||
for (Node n in input) {
|
||||
if (n is Element) {
|
||||
Element e = n;
|
||||
out.add(e.tagName);
|
||||
} else {
|
||||
out.add(n.text);
|
||||
out.add(n.text!);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
|
@ -70,8 +68,8 @@ main() {
|
|||
});
|
||||
|
||||
group('children', () {
|
||||
DocumentFragment fragment;
|
||||
List<Element> children;
|
||||
late DocumentFragment fragment;
|
||||
late List<Element> children;
|
||||
|
||||
init() {
|
||||
fragment = new DocumentFragment();
|
||||
|
@ -87,8 +85,6 @@ main() {
|
|||
]);
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
test('is initially empty', () {
|
||||
children = new DocumentFragment().children;
|
||||
expect(children, equals([]));
|
||||
|
@ -165,7 +161,7 @@ main() {
|
|||
test('query searches the fragment', () {
|
||||
var fragment = new DocumentFragment.html(
|
||||
"<div class='foo'><a>foo</a><b>bar</b></div>");
|
||||
expect(fragment.querySelector(".foo a").tagName, "A");
|
||||
expect(fragment.querySelector(".foo a")!.tagName, "A");
|
||||
expect(_nodeStrings(fragment.querySelectorAll<Element>(".foo *")),
|
||||
equals(["A", "B"]));
|
||||
});
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
library tests.html.events_test;
|
||||
|
||||
import 'dart:async';
|
||||
|
@ -35,7 +33,7 @@ main() {
|
|||
test('EventTarget', () {
|
||||
var element = new Element.tag('test');
|
||||
element.id = 'eventtarget';
|
||||
document.body.append(element);
|
||||
document.body!.append(element);
|
||||
|
||||
var invocationCounter = 0;
|
||||
void handler(Event e) {
|
||||
|
@ -93,7 +91,7 @@ main() {
|
|||
|
||||
var element = new Element.tag('test');
|
||||
element.id = 'eventtarget';
|
||||
document.body.append(element);
|
||||
document.body!.append(element);
|
||||
|
||||
// runZoned executes the function synchronously, but we don't want to
|
||||
// rely on this. We therefore wrap it into an expectAsync.
|
||||
|
@ -101,14 +99,14 @@ main() {
|
|||
var zone = Zone.current;
|
||||
Expect.notEquals(zone, Zone.root);
|
||||
|
||||
StreamSubscription<Event> sub;
|
||||
StreamSubscription<Event>? sub;
|
||||
|
||||
void handler(Event e) {
|
||||
expect(Zone.current, equals(zone));
|
||||
|
||||
scheduleMicrotask(expectAsync0(() {
|
||||
expect(Zone.current, equals(zone));
|
||||
sub.cancel();
|
||||
sub!.cancel();
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
library file_sample;
|
||||
|
||||
import 'dart:async';
|
||||
|
@ -38,33 +36,32 @@ class Logger {
|
|||
|
||||
Logger testLog = new Logger();
|
||||
|
||||
Future<FileSystem> _fileSystem;
|
||||
Future<FileSystem>? _fileSystem;
|
||||
|
||||
DirectoryEntry _myDirectory;
|
||||
late DirectoryEntry _myDirectory;
|
||||
|
||||
Future<FileSystem> get fileSystem async {
|
||||
if (_fileSystem != null) return _fileSystem;
|
||||
if (_fileSystem != null) return _fileSystem!;
|
||||
|
||||
testLog.log('acquire START');
|
||||
_fileSystem = window.requestFileSystem(100);
|
||||
|
||||
var fs = await _fileSystem;
|
||||
var fs = await _fileSystem!;
|
||||
testLog.log('acquire CALLBACK START');
|
||||
expect(fs != null, true);
|
||||
expect(fs.root != null, true);
|
||||
expect(fs.runtimeType, FileSystem);
|
||||
expect(fs.root.runtimeType, DirectoryEntry);
|
||||
testLog.log('acquire CALLBACK END');
|
||||
|
||||
return _fileSystem;
|
||||
return _fileSystem!;
|
||||
}
|
||||
|
||||
Future<FileEntry> createFile() async {
|
||||
var fs = await fileSystem;
|
||||
|
||||
_myDirectory = await fs.root.createDirectory('my_directory');
|
||||
_myDirectory =
|
||||
await fs.root.createDirectory('my_directory') as DirectoryEntry;
|
||||
|
||||
FileEntry fileEntry = await _myDirectory.createFile('log.txt');
|
||||
FileEntry fileEntry = await _myDirectory.createFile('log.txt') as FileEntry;
|
||||
|
||||
expect(fileEntry.isFile, true);
|
||||
expect(fileEntry.name, 'log.txt');
|
||||
|
@ -109,8 +106,6 @@ Future testFileSystemRequest() async {
|
|||
testLog.log('test-first');
|
||||
var fs = await fileSystem;
|
||||
testLog.log('first START');
|
||||
expect(fs != null, true);
|
||||
expect(fs.root != null, true);
|
||||
expect(fs.runtimeType, FileSystem);
|
||||
expect(fs.root.runtimeType, DirectoryEntry);
|
||||
testLog.log('first END');
|
||||
|
@ -120,8 +115,6 @@ Future testFileSystemRequestCreateRW() async {
|
|||
testLog.log('test-second');
|
||||
var fs = await fileSystem;
|
||||
testLog.log('second START');
|
||||
expect(fs != null, true);
|
||||
expect(fs.root != null, true);
|
||||
expect(fs.runtimeType, FileSystem);
|
||||
expect(fs.root.runtimeType, DirectoryEntry);
|
||||
testLog.log('second END');
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
library filereader_test;
|
||||
|
||||
import 'package:async_helper/async_minitest.dart';
|
||||
|
@ -33,8 +31,7 @@ main() {
|
|||
test('readDataUrl', () {
|
||||
var reader = new FileReader();
|
||||
reader.onLoad.listen(expectAsync((event) {
|
||||
String result = reader.result;
|
||||
expect(result is String, isTrue);
|
||||
String result = reader.result as String;
|
||||
expect(result.startsWith('data:'), isTrue);
|
||||
}));
|
||||
reader.readAsDataUrl(new Blob(['ABC']));
|
||||
|
|
|
@ -2,14 +2,12 @@
|
|||
// 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.7
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
var isGamepadList =
|
||||
predicate((x) => x is List<Gamepad>, 'is a List<Gamepad>');
|
||||
predicate((x) => x is List<Gamepad?>, 'is a List<Gamepad?>');
|
||||
|
||||
insertTestDiv() {
|
||||
var element = new Element.tag('div');
|
||||
|
@ -18,7 +16,7 @@ main() {
|
|||
block of text multiple times to see each line
|
||||
highlight with every click of the mouse button.
|
||||
''';
|
||||
document.body.append(element);
|
||||
document.body!.append(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
@ -13,15 +11,15 @@ import 'package:expect/minitest.dart';
|
|||
|
||||
main() {
|
||||
test('test1', () {
|
||||
document.body.children.add(new Element.html(r'''
|
||||
document.body!.children.add(new Element.html(r'''
|
||||
<div id='div1'>
|
||||
Hello World!
|
||||
</div>'''));
|
||||
Element e = document.querySelector('#div1');
|
||||
Element? e = document.querySelector('#div1');
|
||||
expect(e, isNotNull);
|
||||
|
||||
expect(() {
|
||||
confuse(e).onfocus = null;
|
||||
confuse(e!).onfocus = null;
|
||||
}, throwsNoSuchMethodError);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
@ -13,16 +11,16 @@ import 'package:expect/minitest.dart';
|
|||
|
||||
main() {
|
||||
test('test1', () {
|
||||
document.body.children.add(new Element.html(r'''
|
||||
document.body!.children.add(new Element.html(r'''
|
||||
<div id='div1'>
|
||||
Hello World!
|
||||
</div>'''));
|
||||
Element e = document.querySelector('#div1');
|
||||
Element? e = document.querySelector('#div1');
|
||||
Element e2 = new Element.html(r"<div id='xx'>XX</div>");
|
||||
expect(e, isNotNull);
|
||||
|
||||
expect(() {
|
||||
confuse(e).appendChild(e2);
|
||||
confuse(e!).appendChild(e2);
|
||||
}, throwsNoSuchMethodError);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:html';
|
||||
|
||||
|
@ -64,7 +62,6 @@ main() {
|
|||
|
||||
test('override', () {
|
||||
Window win = new MockWindow();
|
||||
expect(win.onBeforeUnload != null, isTrue);
|
||||
expect(win.name, equals("MOCK_NAME"));
|
||||
});
|
||||
|
||||
|
@ -81,7 +78,6 @@ main() {
|
|||
|
||||
test('method', () {
|
||||
HtmlDocument doc = new MockHtmlDocument();
|
||||
expect(doc.body.append(null), equals(null));
|
||||
});
|
||||
|
||||
test('mixin', () {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
@ -15,16 +13,16 @@ main() {
|
|||
Element element = new Element.tag('div');
|
||||
element.id = 'test';
|
||||
element.innerHtml = 'Hello World';
|
||||
document.body.append(element);
|
||||
document.body!.append(element);
|
||||
|
||||
element = document.querySelector('#test');
|
||||
element = document.querySelector('#test')!;
|
||||
expect(element.innerHtml, 'Hello World');
|
||||
element.remove();
|
||||
});
|
||||
test('HTMLTable', () {
|
||||
TableElement table = new Element.tag('table');
|
||||
TableElement table = new Element.tag('table') as TableElement;
|
||||
|
||||
TableRowElement row = new Element.tag('tr');
|
||||
TableRowElement row = new Element.tag('tr') as TableRowElement;
|
||||
table.append(row);
|
||||
|
||||
row.append(new Element.tag('td'));
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
@ -17,7 +15,7 @@ main() {
|
|||
<option value="0">Option0</option>
|
||||
<option value="1">Option1</option>
|
||||
<option value="2">Option2</option>
|
||||
''');
|
||||
''') as SelectElement;
|
||||
final optionsCollection = selectElement.options;
|
||||
|
||||
expect(optionsCollection[0].value, equals('0'));
|
||||
|
|
|
@ -2,13 +2,11 @@
|
|||
// 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.7
|
||||
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
void check(InputElement element, String type, [bool supported = true]) {
|
||||
void check(element, String type, [bool supported = true]) {
|
||||
expect(element is InputElement, true);
|
||||
if (supported) {
|
||||
expect(element.type, type);
|
||||
|
|
|
@ -2,19 +2,17 @@
|
|||
// 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.7
|
||||
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
CanvasElement canvas;
|
||||
var canvas;
|
||||
|
||||
canvas = new Element.tag('canvas');
|
||||
canvas.attributes['width'] = '100';
|
||||
canvas.attributes['height'] = '100';
|
||||
document.body.append(canvas);
|
||||
document.body!.append(canvas);
|
||||
|
||||
var isCanvasRenderingContext = predicate(
|
||||
(x) => x is CanvasRenderingContext, 'is a CanvasRenderingContext');
|
||||
|
@ -45,7 +43,7 @@ main() {
|
|||
expect(canvas, isNotImageData);
|
||||
// expect(canvas, isNot(isCanvasPixelArray));
|
||||
|
||||
CanvasRenderingContext2D context = canvas.getContext('2d');
|
||||
var context = canvas.getContext('2d');
|
||||
expect(context, isCanvasRenderingContext);
|
||||
expect(context, isCanvasRenderingContext2D);
|
||||
expect(context, isNotElement);
|
||||
|
@ -54,8 +52,8 @@ main() {
|
|||
// expect(context, isNot(isCanvasPixelArray));
|
||||
|
||||
// FIXME(b/5286633): Interface injection type check workaround.
|
||||
var image = context.createImageData(
|
||||
canvas.width as dynamic, canvas.height as dynamic);
|
||||
var image = (context as CanvasRenderingContext2D)
|
||||
.createImageData(canvas.width as dynamic, canvas.height as dynamic);
|
||||
expect(image, isNotCanvasRenderingContext);
|
||||
expect(image, isNotCanvasRenderingContext2D);
|
||||
expect(image, isNotElement);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
library KeyboardEventTest;
|
||||
|
||||
import 'dart:html';
|
||||
|
@ -23,11 +21,11 @@ void keydownHandlerTest(KeyEvent e) {
|
|||
|
||||
void testKeys() {
|
||||
var subscription =
|
||||
KeyboardEventStream.onKeyDown(document.body).listen(keydownHandlerTest);
|
||||
KeyboardEventStream.onKeyDown(document.body!).listen(keydownHandlerTest);
|
||||
var subscription2 =
|
||||
KeyEvent.keyDownEvent.forTarget(document.body).listen(keydownHandlerTest);
|
||||
var subscription3 =
|
||||
document.body.onKeyDown.listen((e) => print('regular listener'));
|
||||
document.body!.onKeyDown.listen((e) => print('regular listener'));
|
||||
subscription.cancel();
|
||||
subscription2.cancel();
|
||||
subscription3.cancel();
|
||||
|
@ -35,8 +33,8 @@ void testKeys() {
|
|||
|
||||
void testConstructKeyEvent() {
|
||||
int handlerCallCount = 0;
|
||||
CustomStream<KeyEvent> stream =
|
||||
KeyEvent.keyPressEvent.forTarget(document.body);
|
||||
CustomStream<KeyEvent> stream = KeyEvent.keyPressEvent
|
||||
.forTarget(document.body!) as CustomStream<KeyEvent>;
|
||||
var subscription = stream.listen((keyEvent) {
|
||||
expect(keyEvent.charCode, 97);
|
||||
expect(keyEvent.keyCode, 65);
|
||||
|
@ -64,11 +62,11 @@ void testKeyEventSequence() {
|
|||
// Press "?" by simulating "shift" and then the key that has "/" and "?" on
|
||||
// it.
|
||||
CustomStream<KeyEvent> streamDown =
|
||||
KeyEvent.keyDownEvent.forTarget(document.body);
|
||||
CustomStream<KeyEvent> streamPress =
|
||||
KeyEvent.keyPressEvent.forTarget(document.body);
|
||||
KeyEvent.keyDownEvent.forTarget(document.body!) as CustomStream<KeyEvent>;
|
||||
CustomStream<KeyEvent> streamPress = KeyEvent.keyPressEvent
|
||||
.forTarget(document.body!) as CustomStream<KeyEvent>;
|
||||
CustomStream<KeyEvent> streamUp =
|
||||
KeyEvent.keyUpEvent.forTarget(document.body);
|
||||
KeyEvent.keyUpEvent.forTarget(document.body!) as CustomStream<KeyEvent>;
|
||||
|
||||
var subscription = streamDown.listen((keyEvent) {
|
||||
expect(keyEvent.keyCode, predicate([16, 191].contains));
|
||||
|
@ -109,7 +107,7 @@ void testKeyEventKeyboardEvent() {
|
|||
handlerCallCount++;
|
||||
});
|
||||
CustomStream<KeyEvent> streamDown =
|
||||
KeyEvent.keyDownEvent.forTarget(document.body);
|
||||
KeyEvent.keyDownEvent.forTarget(document.body!) as CustomStream<KeyEvent>;
|
||||
streamDown.add(new KeyEvent('keydown', keyCode: 16, charCode: 0));
|
||||
expect(handlerCallCount, 1);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
import 'dart:html';
|
||||
import 'dart:svg' as svg;
|
||||
|
||||
|
@ -126,7 +124,7 @@ main() {
|
|||
|
||||
node = new DivElement();
|
||||
expect(() {
|
||||
node = node.nodes.first;
|
||||
node = node.nodes.first as Element;
|
||||
}, throwsStateError);
|
||||
});
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
/// This tests HTML validation and sanitization, which is very important
|
||||
/// for prevent XSS or other attacks. If you suppress this, or parts of it
|
||||
/// please make it a critical bug and bring it to the attention of the
|
||||
|
@ -18,8 +16,8 @@ import 'package:expect/minitest.dart';
|
|||
import 'utils.dart';
|
||||
|
||||
void validateHtml(String html, String reference, NodeValidator validator) {
|
||||
var a = document.body.createFragment(html, validator: validator);
|
||||
var b = document.body
|
||||
var a = document.body!.createFragment(html, validator: validator);
|
||||
var b = document.body!
|
||||
.createFragment(reference, treeSanitizer: NodeTreeSanitizer.trusted);
|
||||
|
||||
// Prevent a false pass when both the html and the reference both get entirely
|
||||
|
@ -44,13 +42,13 @@ class RecordingUriValidator implements UriPolicy {
|
|||
}
|
||||
|
||||
void testHtml(String name, NodeValidator validator, String html,
|
||||
[String reference]) {
|
||||
[String? reference]) {
|
||||
test(name, () {
|
||||
if (reference == null) {
|
||||
reference = html;
|
||||
}
|
||||
|
||||
validateHtml(html, reference, validator);
|
||||
validateHtml(html, reference!, validator);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -113,10 +111,10 @@ main() {
|
|||
'<img src="http://example.com/foo"/>'
|
||||
'</template>';
|
||||
|
||||
var fragment = document.body.createFragment(html, validator: validator);
|
||||
var fragment = document.body!.createFragment(html, validator: validator);
|
||||
var template = fragment.nodes.single as TemplateElement;
|
||||
|
||||
var expectedContent = document.body.createFragment('<div></div>'
|
||||
var expectedContent = document.body!.createFragment('<div></div>'
|
||||
'<img/>');
|
||||
|
||||
validateNodeTree(template.content, expectedContent);
|
||||
|
@ -124,8 +122,8 @@ main() {
|
|||
|
||||
test("appendHtml is sanitized", () {
|
||||
var html = '<body background="s"></body><div></div>';
|
||||
document.body.appendHtml('<div id="stuff"></div>');
|
||||
var stuff = document.querySelector("#stuff");
|
||||
document.body!.appendHtml('<div id="stuff"></div>');
|
||||
var stuff = document.querySelector("#stuff")!;
|
||||
stuff.appendHtml(html);
|
||||
expect(stuff.childNodes.length, 1);
|
||||
stuff.remove();
|
||||
|
@ -382,26 +380,26 @@ main() {
|
|||
|
||||
test('does not throw on valid syntax', () {
|
||||
expect(() {
|
||||
document.body.createFragment('<div></div>', validator: validator);
|
||||
document.body!.createFragment('<div></div>', validator: validator);
|
||||
}, returnsNormally);
|
||||
});
|
||||
|
||||
test('throws on invalid elements', () {
|
||||
expect(() {
|
||||
document.body.createFragment('<foo></foo>', validator: validator);
|
||||
document.body!.createFragment('<foo></foo>', validator: validator);
|
||||
}, validationError);
|
||||
});
|
||||
|
||||
test('throws on invalid attributes', () {
|
||||
expect(() {
|
||||
document.body
|
||||
document.body!
|
||||
.createFragment('<div foo="bar"></div>', validator: validator);
|
||||
}, validationError);
|
||||
});
|
||||
|
||||
test('throws on invalid attribute values', () {
|
||||
expect(() {
|
||||
document.body.createFragment('<img src="http://example.com/foo.jpg"/>',
|
||||
document.body!.createFragment('<img src="http://example.com/foo.jpg"/>',
|
||||
validator: validator);
|
||||
}, validationError);
|
||||
});
|
||||
|
@ -456,10 +454,10 @@ main() {
|
|||
"");
|
||||
|
||||
test('tagName makes containing form invalid', () {
|
||||
var fragment = document.body.createFragment(
|
||||
var fragment = document.body!.createFragment(
|
||||
"<form onmouseover='alert(2)'><input name='tagName'>",
|
||||
validator: validator);
|
||||
var form = fragment.lastChild as FormElement;
|
||||
var form = fragment.lastChild as FormElement?;
|
||||
// If the tagName was clobbered, the sanitizer should have removed
|
||||
// the whole thing and form is null.
|
||||
// If the tagName was not clobbered, then there will be content,
|
||||
|
@ -471,9 +469,9 @@ main() {
|
|||
});
|
||||
|
||||
test('tagName without mouseover', () {
|
||||
var fragment = document.body
|
||||
var fragment = document.body!
|
||||
.createFragment("<form><input name='tagName'>", validator: validator);
|
||||
var form = fragment.lastChild as FormElement;
|
||||
var form = fragment.lastChild as FormElement?;
|
||||
// If the tagName was clobbered, the sanitizer should have removed
|
||||
// the whole thing and form is null.
|
||||
// If the tagName was not clobbered, then there will be content,
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
@JS()
|
||||
library postmessage_anonymous_test;
|
||||
|
||||
|
@ -31,7 +29,7 @@ const String TEST_MSG = "hello world";
|
|||
class Message {
|
||||
external String get recipient;
|
||||
external String get msg;
|
||||
external factory Message({String recipient, String msg});
|
||||
external factory Message({required String recipient, required String msg});
|
||||
}
|
||||
|
||||
main() {
|
||||
|
@ -51,5 +49,5 @@ void injectSource(String code) {
|
|||
final script = new ScriptElement();
|
||||
script.type = 'text/javascript';
|
||||
script.innerHtml = code;
|
||||
document.body.append(script);
|
||||
document.body!.append(script);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
@ -13,7 +11,7 @@ main() {
|
|||
final canvas = new CanvasElement(width: 200, height: 200);
|
||||
canvas.id = 'testcanvas';
|
||||
final element = new Element.html("<div><br/><img/><input/><img/></div>");
|
||||
document.body.nodes.addAll([div, canvas, element]);
|
||||
document.body!.nodes.addAll([div, canvas, element]);
|
||||
|
||||
var isCanvasElement =
|
||||
predicate((x) => x is CanvasElement, 'is a CanvasElement');
|
||||
|
@ -21,15 +19,15 @@ main() {
|
|||
predicate((x) => x is ImageElement, 'is an ImageElement');
|
||||
|
||||
test('query', () {
|
||||
Element e = querySelector('#testcanvas');
|
||||
Element? e = querySelector('#testcanvas');
|
||||
expect(e, isNotNull);
|
||||
expect(e.id, 'testcanvas');
|
||||
expect(e!.id, 'testcanvas');
|
||||
expect(e, isCanvasElement);
|
||||
expect(e, canvas);
|
||||
});
|
||||
|
||||
test('query (None)', () {
|
||||
Element e = querySelector('#nothere');
|
||||
Element? e = querySelector('#nothere');
|
||||
expect(e, isNull);
|
||||
});
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
library interactive_test;
|
||||
|
||||
import 'dart:async';
|
||||
|
@ -13,13 +11,15 @@ import 'package:async_helper/async_minitest.dart';
|
|||
import 'package:async_helper/async_helper.dart';
|
||||
|
||||
main() async {
|
||||
bool thenEstimateBefore, thenEstimateAfter, thenEstimateDone = false;
|
||||
Map thenEstimate;
|
||||
bool thenEstimateBefore = false;
|
||||
bool thenEstimateAfter = false;
|
||||
bool thenEstimateDone = false;
|
||||
late Map thenEstimate;
|
||||
test('Basic Promise Test', () async {
|
||||
try {
|
||||
thenEstimateBefore = true;
|
||||
window.navigator.storage.estimate().then((value) {
|
||||
thenEstimate = value;
|
||||
thenEstimate = value!;
|
||||
thenEstimateDone = true;
|
||||
});
|
||||
thenEstimateAfter = true;
|
||||
|
@ -27,7 +27,7 @@ main() async {
|
|||
fail("StorageManger failed: $msg");
|
||||
}
|
||||
|
||||
Map estimate = await window.navigator.storage.estimate();
|
||||
Map estimate = await window.navigator.storage.estimate() as Map;
|
||||
|
||||
expect(thenEstimate['usage'] >= 0, true);
|
||||
expect(thenEstimate['quota'] > 1, true);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:html';
|
||||
|
||||
|
@ -13,11 +11,11 @@ class StreamHelper {
|
|||
var _a;
|
||||
StreamHelper() {
|
||||
_a = new TextInputElement();
|
||||
document.body.append(_a);
|
||||
document.body!.append(_a);
|
||||
}
|
||||
|
||||
Element get element => _a;
|
||||
Stream<Event> get stream => _a.onFocus;
|
||||
Stream<Event?> get stream => _a.onFocus;
|
||||
|
||||
// Causes an event on a to be fired.
|
||||
void pulse() {
|
||||
|
@ -31,7 +29,7 @@ main() {
|
|||
var helper = new StreamHelper();
|
||||
|
||||
var callCount = 0;
|
||||
helper.stream.listen((Event e) {
|
||||
helper.stream.listen((Event? e) {
|
||||
++callCount;
|
||||
});
|
||||
|
||||
|
@ -48,7 +46,7 @@ main() {
|
|||
// Validates that capturing events fire on parent before child.
|
||||
test('capture', () {
|
||||
var parent = new DivElement();
|
||||
document.body.append(parent);
|
||||
document.body!.append(parent);
|
||||
|
||||
var helper = new StreamHelper();
|
||||
parent.append(helper.element);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
import 'dart:html';
|
||||
import 'dart:svg' as svg;
|
||||
|
||||
|
@ -15,7 +13,7 @@ main() {
|
|||
|
||||
test('simpleRect', () {
|
||||
var div = new Element.tag('div');
|
||||
document.body.append(div);
|
||||
document.body!.append(div);
|
||||
div.setInnerHtml(r'''
|
||||
<svg id='svg1' width='200' height='100'>
|
||||
<rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect>
|
||||
|
@ -25,7 +23,7 @@ main() {
|
|||
var e = document.querySelector('#svg1');
|
||||
expect(e, isNotNull);
|
||||
|
||||
svg.RectElement r = document.querySelector('#rect1');
|
||||
svg.RectElement r = document.querySelector('#rect1') as svg.RectElement;
|
||||
expect(r.x.baseVal.value, 10);
|
||||
expect(r.y.baseVal.value, 20);
|
||||
expect(r.height.baseVal.value, 40);
|
||||
|
@ -55,7 +53,7 @@ main() {
|
|||
<rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect>
|
||||
</svg>
|
||||
''', validator: new NodeValidatorBuilder()..allowSvg());
|
||||
document.body.append(element);
|
||||
document.body!.append(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
|
@ -97,7 +95,7 @@ main() {
|
|||
<rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect>
|
||||
</svg>
|
||||
''';
|
||||
document.body.append(element);
|
||||
document.body!.append(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
import 'dart:html';
|
||||
import 'dart:svg' as svg;
|
||||
|
||||
|
@ -14,20 +12,18 @@ main() {
|
|||
predicate((x) => x is svg.SvgSvgElement, 'is a SvgSvgElement');
|
||||
|
||||
List<String> _nodeStrings(Iterable<Node> input) {
|
||||
final out = new List<String>();
|
||||
final List<String> out = [];
|
||||
for (Node n in input) {
|
||||
if (n is Element) {
|
||||
Element e = n;
|
||||
out.add(e.tagName);
|
||||
} else {
|
||||
out.add(n.text);
|
||||
out.add(n.text!);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
testConstructor(String tagName, Function isExpectedClass,
|
||||
[bool expectation = true, allowsInnerHtml = true]) {
|
||||
test(tagName, () {
|
||||
|
@ -471,7 +467,7 @@ main() {
|
|||
var root = new svg.SvgSvgElement();
|
||||
root.append(element);
|
||||
|
||||
document.body.append(root);
|
||||
document.body!.append(root);
|
||||
|
||||
var rect = element.getBoundingClientRect();
|
||||
expect(rect is Rectangle, isTrue);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
import 'dart:html';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:web_gl';
|
||||
|
@ -66,8 +64,9 @@ main() {
|
|||
context.texImage2D(1, 1, 1, 1, 10, 10, 1, 1, pixels);
|
||||
|
||||
canvas = new CanvasElement();
|
||||
document.body.children.add(canvas);
|
||||
CanvasRenderingContext2D context2 = canvas.getContext('2d');
|
||||
document.body!.children.add(canvas);
|
||||
CanvasRenderingContext2D context2 =
|
||||
canvas.getContext('2d') as CanvasRenderingContext2D;
|
||||
context.texImage2D(
|
||||
1, 1, 1, 1, 10, context2.getImageData(10, 10, 10, 10));
|
||||
|
||||
|
@ -83,8 +82,9 @@ main() {
|
|||
context.texSubImage2D(1, 1, 1, 1, 1, 10, 10, 1, pixels);
|
||||
|
||||
canvas = new CanvasElement();
|
||||
document.body.children.add(canvas);
|
||||
CanvasRenderingContext2D context2 = canvas.getContext('2d');
|
||||
document.body!.children.add(canvas);
|
||||
CanvasRenderingContext2D context2 =
|
||||
canvas.getContext('2d') as CanvasRenderingContext2D;
|
||||
context.texSubImage2D(
|
||||
1, 1, 1, 1, 1, 10, context2.getImageData(10, 10, 10, 10));
|
||||
|
||||
|
@ -101,7 +101,7 @@ main() {
|
|||
expect(attributes, isNotNull);
|
||||
expect(attributes, isContextAttributes);
|
||||
|
||||
expect(attributes['alpha'], isBoolean);
|
||||
expect(attributes!['alpha'], isBoolean);
|
||||
expect(attributes['antialias'], isBoolean);
|
||||
expect(attributes['depth'], isBoolean);
|
||||
expect(attributes['premultipliedAlpha'], isBoolean);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
library web_gl_test;
|
||||
|
||||
import 'dart:html';
|
||||
|
@ -77,7 +75,7 @@ main() {
|
|||
expect(name, anyOf(allExtensions), reason: 'unknown extension');
|
||||
var canvas = new CanvasElement();
|
||||
var context = canvas.getContext3d();
|
||||
var supportedExtensions = context.getSupportedExtensions();
|
||||
var supportedExtensions = context.getSupportedExtensions()!;
|
||||
if (supportedExtensions.contains(name)) {
|
||||
var extension = context.getExtension(name);
|
||||
expect(extension, isNotNull);
|
||||
|
@ -102,7 +100,8 @@ main() {
|
|||
const name = 'ANGLE_instanced_arrays';
|
||||
testType(name, isAngleInstancedArrays);
|
||||
test('vertexAttribDivisorAngle', () {
|
||||
AngleInstancedArrays extension = getExtension(name);
|
||||
AngleInstancedArrays? extension =
|
||||
getExtension(name) as AngleInstancedArrays?;
|
||||
if (extension == null) return;
|
||||
expect(extension.vertexAttribDivisorAngle, isFunction);
|
||||
});
|
||||
|
@ -188,7 +187,7 @@ main() {
|
|||
const name = 'WEBGL_draw_buffers';
|
||||
testType(name, isDrawBuffers);
|
||||
test('drawBuffersWebgl', () {
|
||||
DrawBuffers extension = getExtension(name);
|
||||
DrawBuffers? extension = getExtension(name) as DrawBuffers?;
|
||||
if (extension == null) return;
|
||||
expect(extension.drawBuffersWebgl, isFunction);
|
||||
});
|
||||
|
@ -198,7 +197,7 @@ main() {
|
|||
const name = 'WEBGL_lose_context';
|
||||
testType(name, isLoseContext);
|
||||
test('loseContext', () {
|
||||
LoseContext extension = getExtension(name);
|
||||
LoseContext? extension = getExtension(name) as LoseContext?;
|
||||
if (extension == null) return;
|
||||
expect(extension.loseContext, isFunction);
|
||||
});
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.7
|
||||
|
||||
library WebDBTest;
|
||||
|
||||
import 'dart:async';
|
||||
|
@ -29,7 +27,7 @@ Future<SqlResultSet> queryTable(
|
|||
return transaction.executeSql(sql, []);
|
||||
}
|
||||
|
||||
Future<SqlResultSet> dropTable(SqlTransaction transaction, String tableName,
|
||||
Future<SqlResultSet?> dropTable(SqlTransaction transaction, String tableName,
|
||||
[bool ignoreFailure = false]) async {
|
||||
try {
|
||||
var result = await transaction.executeSql('DROP TABLE $tableName', []);
|
||||
|
@ -42,8 +40,8 @@ Future<SqlResultSet> dropTable(SqlTransaction transaction, String tableName,
|
|||
final tableName = 'test_table';
|
||||
final columnName = 'test_data';
|
||||
|
||||
SqlDatabase db;
|
||||
SqlTransaction tx;
|
||||
late SqlDatabase db;
|
||||
late SqlTransaction tx;
|
||||
|
||||
Future setup() async {
|
||||
if (SqlDatabase.supported) {
|
||||
|
|
Loading…
Reference in a new issue