diff --git a/tests/lib/html/canvas_pixel_array_type_alias_test.dart b/tests/lib/html/canvas_pixel_array_type_alias_test.dart index a62e2b50fbb..3c992defe3b 100644 --- a/tests/lib/html/canvas_pixel_array_type_alias_test.dart +++ b/tests/lib/html/canvas_pixel_array_type_alias_test.dart @@ -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'; @@ -23,7 +21,7 @@ main() { int height = 100; CanvasElement canvas = new CanvasElement(width: width, height: height); - document.body.append(canvas); + document.body!.append(canvas); CanvasRenderingContext2D context = canvas.context2D; diff --git a/tests/lib/html/canvas_test.dart b/tests/lib/html/canvas_test.dart index f2407a02f24..dd3910f69ec 100644 --- a/tests/lib/html/canvas_test.dart +++ b/tests/lib/html/canvas_test.dart @@ -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 CanvasTest; import 'dart:html'; @@ -17,7 +15,7 @@ main() { int height = 100; canvas = new CanvasElement(width: width, height: height); - document.body.append(canvas); + document.body!.append(canvas); context = canvas.context2D; diff --git a/tests/lib/html/client_rect_test.dart b/tests/lib/html/client_rect_test.dart index 1e99ad85a1c..a02fb0dab68 100644 --- a/tests/lib/html/client_rect_test.dart +++ b/tests/lib/html/client_rect_test.dart @@ -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'; @@ -25,7 +23,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; } @@ -38,8 +36,8 @@ main() { }); test("ClientRect ==", () { - var rect1 = document.body.getBoundingClientRect(); - var rect2 = document.body.getBoundingClientRect(); + var rect1 = document.body!.getBoundingClientRect(); + var rect2 = document.body!.getBoundingClientRect(); expect(rect1, isRectangle); expect(rect1, isDomRectReadOnly); expect(rect1, equals(rect2)); diff --git a/tests/lib/html/cross_domain_iframe_test.dart b/tests/lib/html/cross_domain_iframe_test.dart index f9bc0a43644..2f2aab41784 100644 --- a/tests/lib/html/cross_domain_iframe_test.dart +++ b/tests/lib/html/cross_domain_iframe_test.dart @@ -2,22 +2,20 @@ // 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() { var uri = Uri.parse(window.location.href); - var crossOriginPort = int.parse(uri.queryParameters['crossOriginPort']); + var crossOriginPort = int.parse(uri.queryParameters['crossOriginPort']!); var crossOrigin = '${uri.scheme}://${uri.host}:$crossOriginPort'; var crossOriginUrl = '$crossOrigin/root_dart/tests/lib_2/html/cross_domain_iframe_script.html'; var iframe = new IFrameElement(); iframe.src = crossOriginUrl; - document.body.append(iframe); + document.body!.append(iframe); return window.onMessage .where((MessageEvent event) { diff --git a/tests/lib/html/cross_frame_test.dart b/tests/lib/html/cross_frame_test.dart index 73add2d28cb..def8d7151d1 100644 --- a/tests/lib/html/cross_frame_test.dart +++ b/tests/lib/html/cross_frame_test.dart @@ -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() { var isHistory = predicate((x) => x is History, 'is a History'); final dynamic iframe = new IFrameElement(); - document.body.append(iframe); + document.body!.append(iframe); test('window', () { expect(window, isWindow); diff --git a/tests/lib/html/custom_tags_test.dart b/tests/lib/html/custom_tags_test.dart index b0e818fbc2d..98b60c2c326 100644 --- a/tests/lib/html/custom_tags_test.dart +++ b/tests/lib/html/custom_tags_test.dart @@ -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 @@ import 'utils.dart'; main() { test('create via custom tag', () { var element = new Element.tag('x-basic1')..id = 'basic1'; - document.body.nodes.add(element); + document.body!.nodes.add(element); var queryById = querySelector('#basic1'); expect(queryById, equals(element)); @@ -27,7 +25,7 @@ main() { var element = new DivElement(); element.setInnerHtml("", treeSanitizer: new NullTreeSanitizer()); - document.body.nodes.add(element); + document.body!.nodes.add(element); var queryById = querySelector('#basic2'); expect(queryById is Element, isTrue); @@ -41,7 +39,7 @@ main() { var element = new DivElement(); element.setInnerHtml("
", treeSanitizer: new NullTreeSanitizer()); - document.body.nodes.add(element); + document.body!.nodes.add(element); var queryById = querySelector('#basic3'); expect(queryById is DivElement, isTrue); diff --git a/tests/lib/html/dart_object_local_storage_test.dart b/tests/lib/html/dart_object_local_storage_test.dart index dd5f20ba0ab..3c7130bbaec 100644 --- a/tests/lib/html/dart_object_local_storage_test.dart +++ b/tests/lib/html/dart_object_local_storage_test.dart @@ -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'; @@ -14,7 +12,7 @@ import 'package:expect/minitest.dart'; // effectively testing dart_object_local_storage in the underlying dom // object. main() { - BodyElement body = document.body; + BodyElement body = document.body!; Storage localStorage = window.localStorage; Storage sessionStorage = window.sessionStorage; var element = new Element.tag('canvas'); diff --git a/tests/lib/html/datalistelement_test.dart b/tests/lib/html/datalistelement_test.dart index 12d26cee661..2a9396d564f 100644 --- a/tests/lib/html/datalistelement_test.dart +++ b/tests/lib/html/datalistelement_test.dart @@ -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'; @@ -16,7 +14,7 @@ main() { setUp(() { div = new DivElement(); - document.body.append(div); + document.body!.append(div); div.innerHtml = """ @@ -30,7 +28,7 @@ main() { }); tearDown(() { - document.body.nodes.removeLast(); + document.body!.nodes.removeLast(); }); test('is', () { diff --git a/tests/lib/html/document_test.dart b/tests/lib/html/document_test.dart index 6d563ca3603..334f67e1e51 100644 --- a/tests/lib/html/document_test.dart +++ b/tests/lib/html/document_test.dart @@ -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'; @@ -53,8 +51,8 @@ main() { var doc = document.implementation.createHtmlDocument(''); expect(doc.adoptNode(div), div); expect(div.ownerDocument, doc); - doc.body.nodes.add(div); - expect(doc.querySelector('#foo').text, 'bar'); + doc.body!.nodes.add(div); + expect(doc.querySelector('#foo')!.text, 'bar'); }); test('importNode', () { @@ -63,8 +61,8 @@ main() { var div2 = doc.importNode(div, true); expect(div2, notEquals(div)); expect(div2.ownerDocument, doc); - doc.body.nodes.add(div2); - expect(doc.querySelector('#foo').text, 'bar'); + doc.body!.nodes.add(div2); + expect(doc.querySelector('#foo')!.text, 'bar'); }); test('typeTest1', () { diff --git a/tests/lib/html/event_customevent_test.dart b/tests/lib/html/event_customevent_test.dart index 0599c8312f1..f109a39daa1 100644 --- a/tests/lib/html/event_customevent_test.dart +++ b/tests/lib/html/event_customevent_test.dart @@ -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 EventCustomEventTest; import 'package:async_helper/async_minitest.dart'; @@ -48,7 +46,7 @@ main() { var script = new ScriptElement(); script.text = scriptContents; - document.body.append(script); + document.body!.append(script); expect(fired, isTrue); }); @@ -64,7 +62,7 @@ main() { window.console.log('here' + e.detail); }, false);'''; - document.body.append(new ScriptElement()..text = scriptContents); + document.body!.append(new ScriptElement()..text = scriptContents); var event = new CustomEvent('dart_custom_event', detail: 'dart_message'); window.dispatchEvent(event); @@ -79,7 +77,7 @@ main() { expect(event.detail.dartValue, 666); }); - document.body.dispatchEvent(event); + document.body!.dispatchEvent(event); return future; }); } diff --git a/tests/lib/html/fontface_loaded_test.dart b/tests/lib/html/fontface_loaded_test.dart index 4f3373211d3..5215994bfaf 100644 --- a/tests/lib/html/fontface_loaded_test.dart +++ b/tests/lib/html/fontface_loaded_test.dart @@ -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 fontface_loaded_test; import 'package:async_helper/async_minitest.dart'; @@ -31,7 +29,7 @@ main() { } ''', treeSanitizer: new NullTreeSanitizer()); - document.head.append(style); + document.head!.append(style); test('document fonts - temporary', () async { var atLeastOneFont = false; diff --git a/tests/lib/html/interactive_media_test.dart b/tests/lib/html/interactive_media_test.dart index e21997cedf3..840e16affa9 100644 --- a/tests/lib/html/interactive_media_test.dart +++ b/tests/lib/html/interactive_media_test.dart @@ -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'; @@ -52,7 +50,7 @@ main() async { completer.complete(video); }); - document.body.append(video); + document.body!.append(video); video.src = url; return completer.future; @@ -85,7 +83,7 @@ main() async { completer.complete(video); }); - document.body.append(video); + document.body!.append(video); video.src = url; return completer.future; diff --git a/tests/lib/html/interactive_test.dart b/tests/lib/html/interactive_test.dart index 9e0fcb94700..86b1e6cd986 100644 --- a/tests/lib/html/interactive_test.dart +++ b/tests/lib/html/interactive_test.dart @@ -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'; @@ -14,43 +12,44 @@ import 'utils.dart'; main() { group('KeyEvent', () { keydownHandlerTest(KeyEvent e) { - document.body.innerHtml = - '${document.body.innerHtml}KeyDOWN: CharCode: ${e.charCode}, KeyCode:' - ' ${e.keyCode}
'; + document.body!.innerHtml = + '${document.body!.innerHtml}KeyDOWN: CharCode: ${e.charCode}, ' + 'KeyCode: ${e.keyCode}
'; expect(e.charCode, 0); } keypressHandlerTest(KeyEvent e) { - document.body.innerHtml = - '${document.body.innerHtml}KeyPRESS: CharCode: ${e.charCode}, ' + document.body!.innerHtml = + '${document.body!.innerHtml}KeyPRESS: CharCode: ${e.charCode}, ' 'KeyCode: ${e.keyCode}
'; } keyupHandlerTest(KeyEvent e) { - document.body.innerHtml = - '${document.body.innerHtml}KeyUP: CharCode: ${e.charCode}, KeyCode:' + document.body!.innerHtml = + '${document.body!.innerHtml}KeyUP: CharCode: ${e.charCode}, KeyCode:' ' ${e.keyCode}
'; expect(e.charCode, 0); } keyupHandlerTest2(KeyEvent e) { - document.body.innerHtml = - '${document.body.innerHtml}A second KeyUP handler: CharCode: ' + document.body!.innerHtml = + '${document.body!.innerHtml}A second KeyUP handler: CharCode: ' '${e.charCode}, KeyCode: ${e.keyCode}
'; expect(e.charCode, 0); } test('keys', () { - document.body.innerHtml = - '${document.body.innerHtml}To test keyboard event values, press some ' - 'keys on your keyboard.

The charcode for keydown and keyup' - ' should be 0, and the keycode should (generally) be populated with a' - ' value. Keycode and charcode should both have values for the ' + document.body!.innerHtml = + '${document.body!.innerHtml}To test keyboard event values, press ' + 'some keys on your keyboard.

The charcode for keydown and ' + 'keyup should be 0, and the keycode should (generally) be populated ' + 'with a value. Keycode and charcode should both have values for the ' 'keypress event.'; - KeyboardEventStream.onKeyDown(document.body).listen(keydownHandlerTest); - KeyboardEventStream.onKeyPress(document.body).listen(keypressHandlerTest); - KeyboardEventStream.onKeyUp(document.body).listen(keyupHandlerTest); - KeyboardEventStream.onKeyUp(document.body).listen(keyupHandlerTest2); + KeyboardEventStream.onKeyDown(document.body!).listen(keydownHandlerTest); + KeyboardEventStream.onKeyPress(document.body!) + .listen(keypressHandlerTest); + KeyboardEventStream.onKeyUp(document.body!).listen(keyupHandlerTest); + KeyboardEventStream.onKeyUp(document.body!).listen(keyupHandlerTest2); }); }); } diff --git a/tests/lib/html/postmessage_structured_test.dart b/tests/lib/html/postmessage_structured_test.dart index c67d2e3d99b..ace743df6d5 100644 --- a/tests/lib/html/postmessage_structured_test.dart +++ b/tests/lib/html/postmessage_structured_test.dart @@ -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 postmessage_js_test; import 'dart:async'; @@ -21,7 +19,7 @@ void injectSource(String code) { final script = new ScriptElement(); script.type = 'text/javascript'; script.innerHtml = code; - document.body.append(script); + document.body!.append(script); } Future go(String name, dynamic value) { @@ -179,10 +177,10 @@ Future iframe() async { Future postMessageClonesData() { var iframe = new IFrameElement(); var future = iframe.onLoad.first.then((_) { - iframe.contentWindow.postMessage(new HashMap(), '*'); + iframe.contentWindow!.postMessage(new HashMap(), '*'); }); iframe.src = 'about:blank'; - document.body.append(iframe); + document.body!.append(iframe); return future; } diff --git a/tests/lib/html/queryall_test.dart b/tests/lib/html/queryall_test.dart index 160d816793f..6516a3c3666 100644 --- a/tests/lib/html/queryall_test.dart +++ b/tests/lib/html/queryall_test.dart @@ -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'; @@ -16,7 +14,7 @@ main() { var div = new DivElement(); div.id = 'test'; - document.body.append(div); + document.body!.append(div); div.nodes.addAll([ new DivElement(), diff --git a/tests/lib/html/range_test.dart b/tests/lib/html/range_test.dart index 6f30145cac3..489d1d9cb95 100644 --- a/tests/lib/html/range_test.dart +++ b/tests/lib/html/range_test.dart @@ -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'; @@ -18,7 +16,7 @@ main() { group('functional', () { test('supported works', () { var range = new Range(); - range.selectNode(document.body); + range.selectNode(document.body!); var expectation = Range.supportsCreateContextualFragment ? returnsNormally : throws; diff --git a/tests/lib/html/shadow_dom_test.dart b/tests/lib/html/shadow_dom_test.dart index 4e9d9f9e730..319998281d4 100644 --- a/tests/lib/html/shadow_dom_test.dart +++ b/tests/lib/html/shadow_dom_test.dart @@ -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'; @@ -31,8 +29,8 @@ main() { shadowRoot.append(paragraph1); shadowRoot.append(new ContentElement()); div2.append(paragraph2); - document.body.append(div1); - document.body.append(div2); + document.body!.append(div1); + document.body!.append(div2); } var expectation = ShadowRoot.supported ? returnsNormally : throws; diff --git a/tests/lib/html/track_element_constructor_test.dart b/tests/lib/html/track_element_constructor_test.dart index 9243a18fc3d..9fa006bc55a 100644 --- a/tests/lib/html/track_element_constructor_test.dart +++ b/tests/lib/html/track_element_constructor_test.dart @@ -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 - // A regression test for dart2js generating illegal JavaScript code // dynamically in non-csp mode. The name of the field "defaultValue" // in JavaScript is "default". This meant that dart2js would create a @@ -18,7 +16,7 @@ import 'package:expect/minitest.dart'; void main() { test('', () { if (!TrackElement.supported) return; - document.body.append(new TrackElement()..defaultValue = true); + document.body!.append(new TrackElement()..defaultValue = true); var trackElement = document.querySelector('track') as TrackElement; if (!trackElement.defaultValue) { throw 'Expected default value to be true'; diff --git a/tests/lib/html/transition_event_test.dart b/tests/lib/html/transition_event_test.dart index a21a45561d9..437601618a1 100644 --- a/tests/lib/html/transition_event_test.dart +++ b/tests/lib/html/transition_event_test.dart @@ -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 transition_event_test; import 'dart:html'; @@ -13,7 +11,7 @@ import 'package:expect/minitest.dart'; Future testTransitionEnd() async { var element = new DivElement(); - document.body.append(element); + document.body!.append(element); element.style.opacity = '0'; element.style.width = '100px'; diff --git a/tests/lib/html/trusted_html_tree_sanitizer_test.dart b/tests/lib/html/trusted_html_tree_sanitizer_test.dart index 42a7975e07b..a0d92edc7d2 100644 --- a/tests/lib/html/trusted_html_tree_sanitizer_test.dart +++ b/tests/lib/html/trusted_html_tree_sanitizer_test.dart @@ -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 @@ -39,17 +37,17 @@ main() { tearDown(restoreOldAdoptNode); test('setInnerHtml', () { - document.body.setInnerHtml('
something
', + document.body!.setInnerHtml('
something
', treeSanitizer: NodeTreeSanitizer.trusted); - expect(document.body.innerHtml, '
something
'); + expect(document.body!.innerHtml, '
something
'); }); test("appendHtml", () { - var oldStuff = document.body.innerHtml; + var oldStuff = document.body!.innerHtml; var newStuff = '
content
'; - document.body + document.body! .appendHtml(newStuff, treeSanitizer: NodeTreeSanitizer.trusted); - expect(document.body.innerHtml, oldStuff + newStuff); + expect(document.body!.innerHtml, oldStuff + newStuff); }); }); @@ -57,7 +55,7 @@ main() { setUp(makeDocumentFragmentAdoptionThrow); tearDown(restoreOldAdoptNode); test('untrusted', () { - expect(() => document.body.innerHtml = "

anything

", throws); + expect(() => document.body!.innerHtml = "

anything

", throws); }); }); } diff --git a/tests/lib/html/unknownelement_test.dart b/tests/lib/html/unknownelement_test.dart index 28c28e4ed7a..a964bb8ec5f 100644 --- a/tests/lib/html/unknownelement_test.dart +++ b/tests/lib/html/unknownelement_test.dart @@ -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'; @@ -16,7 +14,7 @@ main() { foo.id = 'foo'; var bar = new Element.tag('bar'); bar.id = 'bar'; - document.body.nodes.addAll([foo, bar]); + document.body!.nodes.addAll([foo, bar]); test('type-check', () { expect(foo, isUnknownElement); diff --git a/tests/lib/html/xhr_test.dart b/tests/lib/html/xhr_test.dart index 41f9f14bbfe..3922ec7a346 100644 --- a/tests/lib/html/xhr_test.dart +++ b/tests/lib/html/xhr_test.dart @@ -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 XHRTest; import 'dart:async'; @@ -187,7 +185,7 @@ Future testXhrPostFormData() async { var parts = []; for (var key in data.keys) { parts.add('${Uri.encodeQueryComponent(key)}=' - '${Uri.encodeQueryComponent(data[key])}'); + '${Uri.encodeQueryComponent(data[key]!)}'); } var encodedData = parts.join('&'); @@ -226,7 +224,7 @@ Future testResponseHeaders() async { var contentTypeHeader = xhr.responseHeaders['content-type']; expect(contentTypeHeader, isNotNull); // Should be like: 'text/plain; charset=utf-8' - expect(contentTypeHeader.contains('text/plain'), isTrue); + expect(contentTypeHeader!.contains('text/plain'), isTrue); expect(contentTypeHeader.contains('charset=utf-8'), isTrue); }