mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
Remove uses of unittest in the HTML tests where possible.
This finishes going through the dev_compiler HTML tests and switches out unittest for minitest wherever possible. In the process, it gets another 10 tests strong mode clean, and gets several more passing, and more not skipped. With this CL, we're running another 50 more HTML tests (though some are expected to fail, mostly because of #27578). R=jacobr@google.com, vsm@google.com Review URL: https://codereview.chromium.org/2419863002 .
This commit is contained in:
parent
72e3d13db2
commit
60a966605d
|
@ -410,9 +410,6 @@ define(['dart_sdk', 'async_helper', 'expect', 'unittest', 'require'],
|
|||
'utf85_test': skip_timeout,
|
||||
},
|
||||
|
||||
// TODO(jacobr): enable more of the html tests in unittest once they have
|
||||
// more hope of passing. Triage tests that can never run in this test
|
||||
// runner and track them separately.
|
||||
'lib/html': {
|
||||
'async_spawnuri_test': async_unittest,
|
||||
'async_test': async_unittest,
|
||||
|
@ -440,10 +437,7 @@ define(['dart_sdk', 'async_helper', 'expect', 'unittest', 'require'],
|
|||
'element_classes_test': 'fail', // sdk#27579.
|
||||
'element_classes_svg_test': 'fail', // sdk#27579.
|
||||
|
||||
// This fails because we get 150 instead of 10 on line 45.
|
||||
'element_dimensions_test': 'fail',
|
||||
|
||||
// Failure: 'Expected 364 to be in the inclusive range [111, 160].'.
|
||||
// Failure: 'Expected 56 to be in the inclusive range [111, 160].'.
|
||||
'element_offset_test': 'fail',
|
||||
'element_test': async_unittest,
|
||||
'element_types_test': 'fail', // sdk#27578.
|
||||
|
@ -461,9 +455,6 @@ define(['dart_sdk', 'async_helper', 'expect', 'unittest', 'require'],
|
|||
'fontface_test': 'fail',
|
||||
'form_data_test': async_unittest,
|
||||
'history_test': async_unittest,
|
||||
|
||||
// Failing because innerHtml should be 'Hello World' but was ''.
|
||||
'htmlelement_test': 'fail',
|
||||
'indexeddb_1_test': async_unittest,
|
||||
'indexeddb_2_test': async_unittest,
|
||||
'indexeddb_3_test': async_unittest,
|
||||
|
@ -482,92 +473,59 @@ define(['dart_sdk', 'async_helper', 'expect', 'unittest', 'require'],
|
|||
|
||||
// The "typed literal" test fails because the object does not have "_c".
|
||||
'js_util_test': 'fail',
|
||||
'keyboard_event_test': ['unittest', 'skip', 'fail'],
|
||||
'localstorage_test': ['unittest', 'skip', 'fail'],
|
||||
'location_test': ['unittest', 'skip', 'fail'],
|
||||
'mediasource_test': ['unittest', 'skip', 'fail'],
|
||||
'media_stream_test': ['unittest', 'skip', 'fail'],
|
||||
'messageevent_test': ['unittest', 'skip', 'fail'],
|
||||
'mirrors_js_typed_interop_test': ['unittest', 'skip', 'fail'],
|
||||
'mouse_event_test': ['unittest', 'skip', 'fail'],
|
||||
'mutationobserver_test': ['unittest', 'skip', 'fail'],
|
||||
'native_gc_test': ['unittest', 'skip', 'fail'],
|
||||
'navigator_test': ['unittest', 'skip', 'fail'],
|
||||
'node_test': ['unittest', 'skip', 'fail'],
|
||||
'node_validator_important_if_you_suppress_make_the_bug_critical_test': ['unittest', 'skip', 'fail'],
|
||||
'non_instantiated_is_test': ['unittest', 'skip', 'fail'],
|
||||
'notification_test': ['unittest', 'skip', 'fail'],
|
||||
'performance_api_test': ['unittest', 'skip', 'fail'],
|
||||
'postmessage_structured_test': ['unittest', 'skip', 'fail'],
|
||||
'private_extension_member_test': ['unittest', 'skip', 'fail'],
|
||||
'queryall_test': ['unittest', 'skip', 'fail'],
|
||||
'query_test': ['unittest', 'skip', 'fail'],
|
||||
'range_test': ['unittest', 'skip', 'fail'],
|
||||
'request_animation_frame_test': ['unittest', 'skip', 'fail'],
|
||||
'resource_http_test': ['unittest', 'skip', 'fail'],
|
||||
'rtc_test': ['unittest', 'skip', 'fail'],
|
||||
'selectelement_test': ['unittest', 'skip', 'fail'],
|
||||
'serialized_script_value_test': ['unittest', 'skip', 'fail'],
|
||||
'shadow_dom_test': ['unittest', 'skip', 'fail'],
|
||||
'shadowroot_test': ['unittest', 'skip', 'fail'],
|
||||
'speechrecognition_test': ['unittest', 'skip', 'fail'],
|
||||
'storage_test': ['unittest', 'skip', 'fail'],
|
||||
'streams_test': ['unittest', 'skip', 'fail'],
|
||||
'svgelement_test': ['unittest', 'skip', 'fail'],
|
||||
'svg_test': ['unittest', 'skip', 'fail'],
|
||||
'table_test': ['unittest', 'skip', 'fail'],
|
||||
'touchevent_test': ['unittest', 'skip', 'fail'],
|
||||
'track_element_constructor_test': ['unittest', 'skip', 'fail'],
|
||||
'transferables_test': ['unittest', 'skip', 'fail'],
|
||||
'transition_event_test': ['unittest', 'skip', 'fail'],
|
||||
'trusted_html_tree_sanitizer_test': ['unittest', 'skip', 'fail'],
|
||||
'typed_arrays_1_test': ['unittest', 'skip', 'fail'],
|
||||
'typed_arrays_2_test': ['unittest', 'skip', 'fail'],
|
||||
'typed_arrays_3_test': ['unittest', 'skip', 'fail'],
|
||||
'typed_arrays_4_test': ['unittest', 'skip', 'fail'],
|
||||
'typed_arrays_5_test': ['unittest', 'skip', 'fail'],
|
||||
'typed_arrays_arraybuffer_test': ['unittest', 'skip', 'fail'],
|
||||
'typed_arrays_dataview_test': ['unittest', 'skip', 'fail'],
|
||||
'typed_arrays_range_checks_test': ['unittest', 'skip', 'fail'],
|
||||
'typed_arrays_simd_test': ['unittest', 'skip', 'fail'],
|
||||
'typing_test': ['unittest', 'skip', 'fail'],
|
||||
'unknownelement_test': ['unittest', 'skip', 'fail'],
|
||||
'uri_test': ['unittest', 'skip', 'fail'],
|
||||
'url_test': ['unittest', 'skip', 'fail'],
|
||||
'webgl_1_test': ['unittest', 'skip', 'fail'],
|
||||
'websocket_test': ['unittest', 'skip', 'fail'],
|
||||
'websql_test': ['unittest', 'skip', 'fail'],
|
||||
'wheelevent_test': ['unittest', 'skip', 'fail'],
|
||||
'window_eq_test': ['unittest', 'skip', 'fail'],
|
||||
'window_mangling_test': ['unittest', 'skip', 'fail'],
|
||||
'window_nosuchmethod_test': ['unittest', 'skip', 'fail'],
|
||||
'window_test': ['unittest', 'skip', 'fail'],
|
||||
'worker_api_test': ['unittest', 'skip', 'fail'],
|
||||
'worker_test': ['unittest', 'skip', 'fail'],
|
||||
'wrapping_collections_test': ['unittest', 'skip', 'fail'],
|
||||
'xhr_cross_origin_test': ['unittest', 'skip', 'fail'],
|
||||
'xhr_test': ['unittest', 'skip', 'fail'],
|
||||
'xsltprocessor_test': ['unittest', 'skip', 'fail'],
|
||||
'keyboard_event_test': async_unittest,
|
||||
|
||||
'js_typed_interop_default_arg_test_none_multi': ['unittest', 'skip', 'fail'],
|
||||
'js_typed_interop_default_arg_test_explicit_argument_multi': ['unittest', 'skip', 'fail'],
|
||||
'mediasource_test': 'fail', // sdk#27578.
|
||||
'media_stream_test': 'fail', // sdk#27578.
|
||||
'messageevent_test': 'fail', // sdk#27578.
|
||||
|
||||
// Should throw but does not.
|
||||
'mirrors_js_typed_interop_test': 'fail',
|
||||
|
||||
'mutationobserver_test': async_unittest,
|
||||
'native_gc_test': async_unittest,
|
||||
'node_validator_important_if_you_suppress_make_the_bug_critical_test': 'fail', // sdk#27578.
|
||||
'notification_test': 'fail', // sdk#27578.
|
||||
'performance_api_test': 'fail', // sdk#27578.
|
||||
'postmessage_structured_test': async_unittest,
|
||||
'range_test': 'fail', // sdk#27578.
|
||||
'request_animation_frame_test': async_unittest,
|
||||
'resource_http_test': async_unittest,
|
||||
'rtc_test': 'fail', // sdk#27578.
|
||||
|
||||
// Expected 1, got null.
|
||||
'serialized_script_value_test': 'fail',
|
||||
'shadow_dom_test': 'fail', // sdk#27578.
|
||||
'shadowroot_test': 'fail', // sdk#27578.
|
||||
'speechrecognition_test': 'fail', // sdk#27578.
|
||||
'svgelement_test': 'fail', // sdk#27578.
|
||||
'touchevent_test': 'fail', // sdk#27578.
|
||||
'track_element_constructor_test': 'fail', // sdk#27578.
|
||||
'transferables_test': async_unittest,
|
||||
'transition_event_test': async_unittest,
|
||||
'url_test': async_unittest,
|
||||
'websocket_test': async_unittest,
|
||||
'websql_test': async_unittest,
|
||||
'wheelevent_test': async_unittest,
|
||||
'worker_api_test': async_unittest,
|
||||
'worker_test': async_unittest,
|
||||
|
||||
'xhr_cross_origin_test': async_unittest,
|
||||
'xhr_test': async_unittest,
|
||||
'xsltprocessor_test': 'fail', // sdk#27578.
|
||||
|
||||
// Failing when it gets 3 instead of 42.
|
||||
'js_typed_interop_default_arg_test_default_value_multi': 'fail',
|
||||
},
|
||||
|
||||
'lib/html/custom': {
|
||||
'attribute_changed_callback_test': ['unittest', 'skip', 'fail'],
|
||||
'constructor_calls_created_synchronously_test':
|
||||
['unittest', 'skip', 'fail'],
|
||||
'created_callback_test': ['unittest', 'skip', 'fail'],
|
||||
'document_register_basic_test': ['unittest', 'skip', 'fail'],
|
||||
'document_register_type_extensions_test': ['unittest', 'skip', 'fail'],
|
||||
'element_upgrade_test': ['unittest', 'skip', 'fail'],
|
||||
'entered_left_view_test': ['unittest', 'skip', 'fail'],
|
||||
'js_custom_test': ['unittest', 'skip', 'fail'],
|
||||
'mirrors_test': ['unittest', 'skip', 'fail'],
|
||||
'regress_194523002_test': ['unittest', 'skip', 'fail'],
|
||||
'attribute_changed_callback_test': async_unittest,
|
||||
'constructor_calls_created_synchronously_test': async_unittest,
|
||||
'created_callback_test': async_unittest,
|
||||
'entered_left_view_test': async_unittest,
|
||||
'js_custom_test': async_unittest,
|
||||
'mirrors_test': async_unittest,
|
||||
'regress_194523002_test': async_unittest,
|
||||
},
|
||||
|
||||
'lib/math': {
|
||||
|
@ -820,6 +778,11 @@ define(['dart_sdk', 'async_helper', 'expect', 'unittest', 'require'],
|
|||
}
|
||||
}
|
||||
|
||||
// If the test left any lingering detritus in the DOM, blow it away
|
||||
// so it doesn't interfere with later tests.
|
||||
document.body.innerHTML = '';
|
||||
console.log("cleared");
|
||||
|
||||
if (!async_helper.asyncTestStarted) done();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
// 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 document_register_basic_test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
|
||||
class Foo extends HtmlElement {
|
||||
|
@ -45,8 +45,6 @@ class BadF implements HtmlElement {
|
|||
}
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
|
||||
// Adapted from Blink's fast/dom/custom/document-register-basic test.
|
||||
|
||||
setUp(() => customElementsReady);
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
// 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 document_register_type_extensions_test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
|
||||
class Foo extends HtmlElement {
|
||||
|
|
|
@ -2,13 +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.
|
||||
|
||||
library register_element_proxy_test;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:html';
|
||||
import 'dart:js' as js;
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
|
||||
class FooElement extends HtmlElement {
|
||||
|
@ -28,8 +27,6 @@ class FooElement extends HtmlElement {
|
|||
}
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
|
||||
var registered = false;
|
||||
var upgrader;
|
||||
setUp(() => customElementsReady.then((_) {
|
||||
|
|
|
@ -2,49 +2,42 @@
|
|||
// 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 LocalStorageTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
setUp(() {
|
||||
window.localStorage['key1'] = 'val1';
|
||||
window.localStorage['key2'] = 'val2';
|
||||
window.localStorage['key3'] = 'val3';
|
||||
});
|
||||
|
||||
void testWithLocalStorage(String name, fn()) {
|
||||
test(name, () {
|
||||
window.localStorage['key1'] = 'val1';
|
||||
window.localStorage['key2'] = 'val2';
|
||||
window.localStorage['key3'] = 'val3';
|
||||
tearDown(() {
|
||||
window.localStorage.clear();
|
||||
});
|
||||
|
||||
try {
|
||||
fn();
|
||||
} finally {
|
||||
window.localStorage.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
testWithLocalStorage('containsValue', () {
|
||||
test('containsValue', () {
|
||||
expect(window.localStorage.containsValue('does not exist'), isFalse);
|
||||
expect(window.localStorage.containsValue('key1'), isFalse);
|
||||
expect(window.localStorage.containsValue('val1'), isTrue);
|
||||
expect(window.localStorage.containsValue('val3'), isTrue);
|
||||
});
|
||||
|
||||
testWithLocalStorage('containsKey', () {
|
||||
test('containsKey', () {
|
||||
expect(window.localStorage.containsKey('does not exist'), isFalse);
|
||||
expect(window.localStorage.containsKey('val1'), isFalse);
|
||||
expect(window.localStorage.containsKey('key1'), isTrue);
|
||||
expect(window.localStorage.containsKey('key3'), isTrue);
|
||||
});
|
||||
|
||||
testWithLocalStorage('[]', () {
|
||||
test('[]', () {
|
||||
expect(window.localStorage['does not exist'], isNull);
|
||||
expect(window.localStorage['key1'], 'val1');
|
||||
expect(window.localStorage['key3'], 'val3');
|
||||
});
|
||||
|
||||
testWithLocalStorage('[]=', () {
|
||||
test('[]=', () {
|
||||
expect(window.localStorage['key4'], isNull);
|
||||
window.localStorage['key4'] = 'val4';
|
||||
expect(window.localStorage['key4'], 'val4');
|
||||
|
@ -54,29 +47,32 @@ main() {
|
|||
expect(window.localStorage['key3'], 'val3-new');
|
||||
});
|
||||
|
||||
testWithLocalStorage('putIfAbsent', () {
|
||||
test('putIfAbsent', () {
|
||||
expect(window.localStorage['key4'], isNull);
|
||||
expect(window.localStorage.putIfAbsent('key4', () => 'val4'), 'val4');
|
||||
expect(window.localStorage['key4'], 'val4');
|
||||
|
||||
expect(window.localStorage['key3'], 'val3');
|
||||
expect(window.localStorage.putIfAbsent('key3',
|
||||
() => expect(false, isTrue, reason: 'should not be called')), 'val3');
|
||||
() {
|
||||
fail('should not be called');
|
||||
return 'unused';
|
||||
}), 'val3');
|
||||
expect(window.localStorage['key3'], 'val3');
|
||||
});
|
||||
|
||||
testWithLocalStorage('remove', () {
|
||||
test('remove', () {
|
||||
expect(window.localStorage.remove('does not exist'), isNull);
|
||||
expect(window.localStorage.remove('key3'), 'val3');
|
||||
expect(window.localStorage, equals({'key1': 'val1', 'key2': 'val2'}));
|
||||
});
|
||||
|
||||
testWithLocalStorage('clear', () {
|
||||
test('clear', () {
|
||||
window.localStorage.clear();
|
||||
expect(window.localStorage, equals({}));
|
||||
});
|
||||
|
||||
testWithLocalStorage('forEach', () {
|
||||
test('forEach', () {
|
||||
Map<String, String> results = {};
|
||||
window.localStorage.forEach((k, v) {
|
||||
results[k] = v;
|
||||
|
@ -84,23 +80,23 @@ main() {
|
|||
expect(results, equals({'key1': 'val1', 'key2': 'val2', 'key3': 'val3'}));
|
||||
});
|
||||
|
||||
testWithLocalStorage('getKeys', () {
|
||||
test('getKeys', () {
|
||||
expect(window.localStorage.keys.toList(),
|
||||
unorderedEquals(['key1', 'key2', 'key3']));
|
||||
});
|
||||
|
||||
testWithLocalStorage('getVals', () {
|
||||
test('getVals', () {
|
||||
expect(window.localStorage.values.toList(),
|
||||
unorderedEquals(['val1', 'val2', 'val3']));
|
||||
});
|
||||
|
||||
testWithLocalStorage('length', () {
|
||||
test('length', () {
|
||||
expect(window.localStorage.length, 3);
|
||||
window.localStorage.clear();
|
||||
expect(window.localStorage.length, 0);
|
||||
});
|
||||
|
||||
testWithLocalStorage('isEmpty', () {
|
||||
test('isEmpty', () {
|
||||
expect(window.localStorage.isEmpty, isFalse);
|
||||
window.localStorage.clear();
|
||||
expect(window.localStorage.isEmpty, isTrue);
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
library LocationTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
var isLocation = predicate((x) => x is Location, 'is a Location');
|
||||
|
||||
test('location hash', () {
|
||||
|
|
|
@ -2,14 +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.
|
||||
|
||||
library media_stream_test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
group('supported_media', () {
|
||||
test('supported', () {
|
||||
expect(MediaStream.supported, true);
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
library mediasource_test;
|
||||
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'dart:html';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
|
||||
var isMediaSource = predicate((x) => x is MediaSource, 'is a MediaSource');
|
||||
|
||||
group('supported', () {
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
library SerializedScriptValueTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
test('new MessageEvent', () {
|
||||
final event = new MessageEvent('type', cancelable: true, data: 'data',
|
||||
origin: 'origin', lastEventId: 'lastEventId');
|
||||
|
|
|
@ -9,8 +9,7 @@ import 'dart:mirrors';
|
|||
import 'dart:html';
|
||||
|
||||
import 'package:js/js.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
_injectJs() {
|
||||
document.body.append(new ScriptElement()
|
||||
|
@ -37,8 +36,6 @@ class Foo {
|
|||
main() {
|
||||
_injectJs();
|
||||
|
||||
useHtmlConfiguration();
|
||||
|
||||
test('dynamic dispatch', () {
|
||||
var f = foo;
|
||||
expect(f.x, 3);
|
||||
|
|
|
@ -2,14 +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.
|
||||
|
||||
library mouse_event_test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
test('relatedTarget', () {
|
||||
var event = new MouseEvent('mouseout');
|
||||
expect(event.relatedTarget, isNull);
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
library NavigatorTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
test('language never returns null', () {
|
||||
expect(window.navigator.language, isNotNull);
|
||||
});
|
||||
main() {
|
||||
Expect.isNotNull(window.navigator.language);
|
||||
}
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
// 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 NodeTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'dart:html';
|
||||
import 'dart:svg' as svg;
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
Node makeNode() => new Element.tag('div');
|
||||
Node makeNodeWithChildren() =>
|
||||
Element makeNodeWithChildren() =>
|
||||
new Element.html("<div>Foo<br/><!--baz--></div>");
|
||||
|
||||
void testUnsupported(String name, void f()) {
|
||||
|
@ -19,8 +18,6 @@ void testUnsupported(String name, void f()) {
|
|||
}
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
|
||||
var isText = predicate((x) => x is Text, 'is a Text');
|
||||
var isComment = predicate((x) => x is Comment, 'is a Comment');
|
||||
var isBRElement = predicate((x) => x is BRElement, 'is a BRElement');
|
||||
|
|
|
@ -10,8 +10,9 @@ library node_validator_test;
|
|||
|
||||
import 'dart:html';
|
||||
import 'dart:svg' as svg;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
import 'utils.dart';
|
||||
|
||||
void validateHtml(String html, String reference, NodeValidator validator) {
|
||||
|
@ -52,8 +53,6 @@ void testHtml(String name, NodeValidator validator, String html,
|
|||
}
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
|
||||
group('DOM_sanitization', () {
|
||||
var validator = new NodeValidatorBuilder.common();
|
||||
|
||||
|
@ -126,7 +125,7 @@ main() {
|
|||
'</template>';
|
||||
|
||||
var fragment = document.body.createFragment(html, validator: validator);
|
||||
var template = fragment.nodes.single;
|
||||
var template = fragment.nodes.single as TemplateElement;
|
||||
|
||||
var expectedContent = document.body.createFragment(
|
||||
'<div></div>'
|
||||
|
@ -149,8 +148,9 @@ main() {
|
|||
var fragment = new DocumentFragment.html(html);
|
||||
fragment.appendHtml('<div id="bad"><script></script></div>');
|
||||
expect(fragment.childNodes.length, 1);
|
||||
expect(fragment.childNodes[0].id, "bad");
|
||||
expect(fragment.childNodes[0].childNodes.length, 0);
|
||||
var child = fragment.childNodes[0] as Element;
|
||||
expect(child.id, "bad");
|
||||
expect(child.childNodes.length, 0);
|
||||
});
|
||||
|
||||
testHtml("sanitizes embed",
|
||||
|
@ -500,7 +500,7 @@ main() {
|
|||
'</svg>';
|
||||
|
||||
var fragment = new DocumentFragment.svg(svgText);
|
||||
var element = fragment.nodes.first;
|
||||
var element = fragment.nodes.first as Element;
|
||||
expect(element is svg.SvgSvgElement, isTrue);
|
||||
expect(element.children[0] is svg.ImageElement, isTrue);
|
||||
});
|
||||
|
@ -542,7 +542,7 @@ main() {
|
|||
var fragment = document.body.createFragment(
|
||||
"<form onmouseover='alert(2)'><input name='tagName'>",
|
||||
validator: validator);
|
||||
var form = fragment.lastChild;
|
||||
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,
|
||||
|
@ -557,7 +557,7 @@ main() {
|
|||
var fragment = document.body.createFragment(
|
||||
"<form><input name='tagName'>",
|
||||
validator: validator);
|
||||
var form = fragment.lastChild;
|
||||
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,
|
||||
|
|
|
@ -6,15 +6,11 @@
|
|||
// checks of native classes that are not instantiated.
|
||||
|
||||
import 'dart:html';
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
var a = [new Object()];
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
|
||||
test('is', () {
|
||||
expect(a[0] is Node, isFalse);
|
||||
});
|
||||
Expect.isFalse(a[0] is Node);
|
||||
}
|
||||
|
|
|
@ -2,15 +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.
|
||||
|
||||
library notification_test;
|
||||
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
group('supported_notification', () {
|
||||
test('supported', () {
|
||||
expect(Notification.supported, true);
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
library PerformanceApiTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
group('supported', () {
|
||||
test('supported', () {
|
||||
expect(Performance.supported, true);
|
||||
|
|
|
@ -13,6 +13,6 @@ main() {
|
|||
//
|
||||
// The createFragment() method sets `_innerHtml` on the element, so we use it
|
||||
// as a test case.
|
||||
Expect.equals("[object DocumentFragment]",
|
||||
Expect.equals("Instance of 'DocumentFragment'",
|
||||
new BRElement().createFragment("Hi").toString());
|
||||
}
|
||||
|
|
|
@ -2,21 +2,18 @@
|
|||
// 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 QueryTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
final div = new DivElement();
|
||||
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]);
|
||||
|
||||
|
||||
var isCanvasElement =
|
||||
predicate((x) => x is CanvasElement, 'is a CanvasElement');
|
||||
var isImageElement =
|
||||
|
@ -47,7 +44,7 @@ main() {
|
|||
expect(l.length, 2);
|
||||
expect(l[0], isImageElement);
|
||||
expect(l[1], isImageElement);
|
||||
expect(l[0], isNot(equals(l[1])));
|
||||
expect(l[0] == l[1], isFalse);
|
||||
});
|
||||
|
||||
test('queryAll (None)', () {
|
||||
|
|
|
@ -2,14 +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
|
||||
|
||||
library NodeListTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
var isElement = predicate((x) => x is Element, 'is an Element');
|
||||
var isCanvasElement =
|
||||
predicate((x) => x is CanvasElement, 'is a CanvasElement');
|
||||
|
@ -45,7 +42,7 @@ main() {
|
|||
});
|
||||
|
||||
test('queryAll-canvas', () {
|
||||
List<CanvasElement> all = queryAll('canvas');
|
||||
var all = queryAll('canvas');
|
||||
for (var e in all) {
|
||||
expect(e, isCanvasElement);
|
||||
}
|
||||
|
@ -61,7 +58,7 @@ main() {
|
|||
|
||||
test('queryAll-where', () {
|
||||
List<Element> all = queryAll('*');
|
||||
Iterable<CanvasElement> canvases = all.where((e) => e is CanvasElement);
|
||||
var canvases = all.where((e) => e is CanvasElement);
|
||||
for (var e in canvases) {
|
||||
expect(e is CanvasElement, isTrue);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
library range_test;
|
||||
|
||||
import 'dart:html';
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
|
||||
group('supported', () {
|
||||
test('supports_createContextualFragment', () {
|
||||
expect(Range.supportsCreateContextualFragment, isTrue);
|
||||
|
|
|
@ -2,17 +2,14 @@
|
|||
// 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 RealTimeCommunicationTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
group('supported', () {
|
||||
test('supported', () {
|
||||
expect(RtcPeerConnection.supported, true);
|
||||
expect(RtcPeerConnection.supported, isTrue);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -2,14 +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.
|
||||
|
||||
library selectelement_test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
test('selectedOptions', () {
|
||||
var element = new SelectElement();
|
||||
element.multiple = false;
|
||||
|
@ -64,14 +61,14 @@ main() {
|
|||
'<optgroup>'
|
||||
'<option>2</option>'
|
||||
'</optgroup>'
|
||||
'</select>');
|
||||
'</select>') as SelectElement;
|
||||
|
||||
expect(element.options.length, 2);
|
||||
element.selectedIndex = 1;
|
||||
|
||||
var optGroup = element.children[1];
|
||||
expect(optGroup is OptGroupElement, isTrue);
|
||||
expect(optGroup.children.single.selected, isTrue);
|
||||
expect((optGroup.children.single as OptionElement).selected, isTrue);
|
||||
expect(element.selectedOptions, optGroup.children);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
library SerializedScriptValueTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
import 'utils.dart';
|
||||
|
||||
serializationTest(name, value) => test(name, () {
|
||||
serializationTest(name, value) {
|
||||
test(name, () {
|
||||
// To check how value is serialized and deserialized, we create a
|
||||
// MessageEvent.
|
||||
final event =
|
||||
new MessageEvent('', data: value, origin: '', lastEventId: '');
|
||||
verifyGraph(value, event.data);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
|
||||
serializationTest('null', null);
|
||||
serializationTest('int', 1);
|
||||
serializationTest('double', 2.39);
|
||||
|
|
|
@ -2,14 +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.
|
||||
|
||||
library ShadowDOMTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
group('supported', () {
|
||||
test('supported', () {
|
||||
expect(ShadowRoot.supported, true);
|
||||
|
@ -17,7 +14,6 @@ main() {
|
|||
});
|
||||
|
||||
group('ShadowDOM_tests', () {
|
||||
|
||||
var div1, div2, shadowRoot, paragraph1, paragraph2;
|
||||
|
||||
init() {
|
||||
|
|
|
@ -2,14 +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.
|
||||
|
||||
library ShadowRootTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
var isShadowRoot =
|
||||
predicate((x) => x is ShadowRoot, 'is a ShadowRoot');
|
||||
|
||||
|
|
|
@ -2,14 +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.
|
||||
|
||||
library speech_recognition_test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
group('supported', () {
|
||||
test('supported', () {
|
||||
expect(SpeechRecognition.supported, true);
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
library StorageTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
test('GetItem', () {
|
||||
final value = window.localStorage['does not exist'];
|
||||
expect(value, isNull);
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
library streams_test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
class StreamHelper {
|
||||
var _a;
|
||||
StreamHelper() {
|
||||
|
@ -22,8 +21,6 @@ class StreamHelper {
|
|||
}
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
|
||||
test('simple', () {
|
||||
var helper = new StreamHelper();
|
||||
|
||||
|
|
|
@ -2,15 +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.
|
||||
|
||||
library SVGTest;
|
||||
import 'dart:html';
|
||||
import 'dart:svg' as svg;
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
|
||||
group('svgPresence', () {
|
||||
var isSvgElement = predicate((x) => x is svg.SvgElement, 'is a SvgElement');
|
||||
|
||||
|
@ -42,8 +39,7 @@ main() {
|
|||
</svg>
|
||||
""");
|
||||
|
||||
expect(logo, isSvgElement);
|
||||
|
||||
expect(logo, isSvgElement);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -66,9 +62,13 @@ main() {
|
|||
var isSvgElement = predicate((x) => x is svg.SvgElement, 'is a SvgElement');
|
||||
var isSvgSvgElement =
|
||||
predicate((x) => x is svg.SvgSvgElement, 'is a SvgSvgElement');
|
||||
var isNotSvgSvgElement =
|
||||
predicate((x) => x is! svg.SvgSvgElement, 'is not a SvgSvgElement');
|
||||
var isNode = predicate((x) => x is Node, 'is a Node');
|
||||
var isSvgNumber = predicate((x) => x is svg.Number, 'is a svg.Number');
|
||||
var isNotSvgNumber = predicate((x) => x is! svg.Number, 'is not a svg.Number');
|
||||
var isSvgRect = predicate((x) => x is svg.Rect, 'is a svg.Rect');
|
||||
var isNotSvgRect = predicate((x) => x is! svg.Rect, 'is not a svg.Rect');
|
||||
|
||||
test('rect_isChecks', () {
|
||||
var div = insertTestDiv();
|
||||
|
@ -80,9 +80,9 @@ main() {
|
|||
expect(r, isNode);
|
||||
|
||||
// Interfaces not implemented.
|
||||
expect(r, isNot(isSvgNumber));
|
||||
expect(r, isNot(isSvgRect));
|
||||
expect(r, isNot(isSvgSvgElement));
|
||||
expect(r, isNotSvgNumber);
|
||||
expect(r, isNotSvgRect);
|
||||
expect(r, isNotSvgSvgElement);
|
||||
|
||||
div.remove();
|
||||
});
|
||||
|
|
|
@ -2,16 +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.
|
||||
|
||||
library SvgElementTest;
|
||||
import 'dart:html';
|
||||
import 'dart:svg' as svg;
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
|
||||
var isSvgSvgElement =
|
||||
predicate((x) => x is svg.SvgSvgElement, 'is a SvgSvgElement');
|
||||
|
||||
|
@ -47,12 +43,12 @@ main() {
|
|||
"</svg>";
|
||||
final el = new svg.SvgElement.svg(svgContent);
|
||||
expect(el, isSvgSvgElement);
|
||||
expect(el.innerHtml, anyOf("<circle></circle><path></path>", '<circle '
|
||||
expect(el.innerHtml, anyOf(["<circle></circle><path></path>", '<circle '
|
||||
'xmlns="http://www.w3.org/2000/svg" /><path '
|
||||
'xmlns="http://www.w3.org/2000/svg" />'));
|
||||
expect(el.outerHtml, anyOf(svgContent,
|
||||
'xmlns="http://www.w3.org/2000/svg" />']));
|
||||
expect(el.outerHtml, anyOf([svgContent,
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">\n '
|
||||
'<circle />\n <path />\n</svg>'));
|
||||
'<circle />\n <path />\n</svg>']));
|
||||
});
|
||||
|
||||
test('has no parent', () =>
|
||||
|
|
|
@ -2,14 +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.
|
||||
|
||||
library TableTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
test('createTBody', () {
|
||||
var table = new TableElement();
|
||||
var head = table.createTHead();
|
||||
|
|
|
@ -2,14 +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.
|
||||
|
||||
library touch_event_test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
group('supported', () {
|
||||
test('supported', () {
|
||||
expect(TouchEvent.supported, true);
|
||||
|
|
|
@ -11,19 +11,18 @@
|
|||
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
void main() {
|
||||
useHtmlConfiguration();
|
||||
test('', () {
|
||||
if (!TrackElement.supported) return;
|
||||
document.body.append(new TrackElement()..defaultValue = true);
|
||||
if (!document.query('track').defaultValue) {
|
||||
var trackElement = document.query('track') as TrackElement;
|
||||
if (!trackElement.defaultValue) {
|
||||
throw 'Expected default value to be true';
|
||||
}
|
||||
document.query('track').defaultValue = false;
|
||||
if (document.query('track').defaultValue) {
|
||||
trackElement.defaultValue = false;
|
||||
if (trackElement.defaultValue) {
|
||||
throw 'Expected default value to be false';
|
||||
}
|
||||
});
|
||||
|
|
|
@ -6,14 +6,13 @@
|
|||
/// 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
|
||||
/// dart:html maintainers.
|
||||
library trusted_html_tree_sanitizer_test;
|
||||
|
||||
import 'dart:js' as js;
|
||||
import 'dart:html';
|
||||
import 'dart:svg' as svg;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
import 'utils.dart';
|
||||
import 'dart:js' as js;
|
||||
|
||||
var oldAdoptNode;
|
||||
var jsDocument;
|
||||
|
@ -33,8 +32,6 @@ restoreOldAdoptNode() {
|
|||
}
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
|
||||
group('not_create_document_fragment', () {
|
||||
setUp(makeDocumentFragmentAdoptionThrow);
|
||||
tearDown(restoreOldAdoptNode);
|
||||
|
|
|
@ -2,17 +2,16 @@
|
|||
// 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 TypedArrays1Test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'dart:html';
|
||||
import 'dart:typed_data';
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
var isnumList = predicate((x) => x is List<num>, 'is a List<num>');
|
||||
var isStringList = predicate((x) => x is List<String>, 'is a List<String>');
|
||||
main() {
|
||||
var isList = predicate((x) => x is List, 'is a List');
|
||||
var isNumList = predicate((x) => x is List<num>, 'is a List<num>');
|
||||
var isNotStringList =
|
||||
predicate((x) => x is! List<String>, 'is not a List<String>');
|
||||
var expectation = Platform.supportsTypedData ? returnsNormally : throws;
|
||||
|
||||
group('supported', () {
|
||||
|
@ -63,8 +62,8 @@ main() {
|
|||
expect(() {
|
||||
var a = new Float32List(10);
|
||||
expect(a, isList);
|
||||
expect(a, isnumList);
|
||||
expect(a, isNot(isStringList));
|
||||
expect(a, isNumList);
|
||||
expect(a, isNotStringList);
|
||||
}, expectation);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,15 +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.
|
||||
|
||||
library TypedArrays2Test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
import 'dart:typed_data';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
// Only perform tests if ArrayBuffer is supported.
|
||||
if (!Platform.supportsTypedData) {
|
||||
return;
|
||||
|
|
|
@ -2,15 +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.
|
||||
|
||||
library TypedArrays3Test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
import 'dart:typed_data';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
// Only perform tests if ArrayBuffer is supported.
|
||||
if (!Platform.supportsTypedData) {
|
||||
return;
|
||||
|
|
|
@ -2,15 +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.
|
||||
|
||||
library TypedArrays4Test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
import 'dart:typed_data';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
// Only perform tests if ArrayBuffer is supported.
|
||||
if (!Platform.supportsTypedData) {
|
||||
return;
|
||||
|
|
|
@ -2,15 +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.
|
||||
|
||||
library typed_arrays_5_test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
import 'dart:typed_data';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
// Only perform tests if ArrayBuffer is supported.
|
||||
if (!Platform.supportsTypedData) {
|
||||
return;
|
||||
|
|
|
@ -2,15 +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.
|
||||
|
||||
library typed_arrays_arraybuffer_test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
import 'dart:typed_data';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
// Only perform tests if ArrayBuffer is supported.
|
||||
if (!Platform.supportsTypedData) {
|
||||
return;
|
||||
|
|
|
@ -2,15 +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.
|
||||
|
||||
library typed_arrays_dataview_test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
import 'dart:typed_data';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
// Only perform tests if ArrayBuffer is supported.
|
||||
if (!Platform.supportsTypedData) {
|
||||
return;
|
||||
|
|
|
@ -2,12 +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.
|
||||
|
||||
library TypedArraysRangeCheckTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
const N = 1024;
|
||||
|
||||
class _TestList {
|
||||
|
@ -28,14 +27,12 @@ _obfuscatedList() {
|
|||
}
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
|
||||
// Only perform tests if ArrayBuffer is supported.
|
||||
if (!Platform.supportsTypedData) {
|
||||
return;
|
||||
}
|
||||
|
||||
test('outOfRangeAccess_dynamic', () {
|
||||
test('outOfRangeAccess', () {
|
||||
var a = _obfuscatedList();
|
||||
|
||||
expect(() => a[a.length], throws);
|
||||
|
@ -54,24 +51,4 @@ main() {
|
|||
expect(() => a[1.5] = 0xdeadbeef, throws);
|
||||
expect(() => a['length'] = 1, throws);
|
||||
});
|
||||
|
||||
test('outOfRange_typed', () {
|
||||
Uint8List a = new Uint8List(N);
|
||||
|
||||
expect(() => a[a.length], throws);
|
||||
expect(() => a[a.length + 1], throws);
|
||||
expect(() => a[a.length + N], throws);
|
||||
|
||||
expect(() => a[-1], throws);
|
||||
expect(() => a[1.5], throws);
|
||||
expect(() => a['length'], throws);
|
||||
|
||||
expect(() => a[a.length] = 0xdeadbeef, throws);
|
||||
expect(() => a[a.length + 1] = 0xdeadbeef, throws);
|
||||
expect(() => a[a.length + N] = 0xdeadbeef, throws);
|
||||
|
||||
expect(() => a[-1] = 0xdeadbeef, throws);
|
||||
expect(() => a[1.5] = 0xdeadbeef, throws);
|
||||
expect(() => a['length'] = 1, throws);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,12 +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.
|
||||
|
||||
library TypedArraysSimdTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
const _FLOATING_POINT_ERROR = 0.0000000001;
|
||||
floatEquals(value) => closeTo(value, _FLOATING_POINT_ERROR);
|
||||
|
||||
|
@ -19,8 +18,6 @@ class MyFloat32x4 {
|
|||
}
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
|
||||
// Only perform tests if ArrayBuffer is supported.
|
||||
if (!Platform.supportsTypedData) {
|
||||
return;
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
library TypingTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
var isStyleSheetList =
|
||||
predicate((x) => x is List<StyleSheet>, 'is a List<StyleSheet>');
|
||||
|
||||
|
@ -23,15 +20,16 @@ main() {
|
|||
});
|
||||
|
||||
test('StyleSheetList', () {
|
||||
List<StyleSheet> asList = window.document.styleSheets;
|
||||
var document = window.document as HtmlDocument;
|
||||
List<StyleSheet> asList = document.styleSheets;
|
||||
expect(asList, isStyleSheetList);
|
||||
// Check it's Iterable.
|
||||
int counter = 0;
|
||||
for (StyleSheet styleSheet in window.document.styleSheets) {
|
||||
for (StyleSheet styleSheet in document.styleSheets) {
|
||||
counter++;
|
||||
}
|
||||
|
||||
// There is one style sheet from the unittest framework.
|
||||
expect(counter, 1);
|
||||
// There are no style sheets.
|
||||
expect(counter, 0);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,22 +2,19 @@
|
|||
// 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 UnknownElementTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
var isUnknownElement =
|
||||
predicate((x) => x is UnknownElement, 'is an UnknownELement');
|
||||
|
||||
var foo = new Element.tag('foo');
|
||||
dynamic foo = new Element.tag('foo');
|
||||
foo.id = 'foo';
|
||||
var bar = new Element.tag('bar');
|
||||
bar.id = 'bar';
|
||||
document.body.nodes.addAll([foo, bar]);
|
||||
document.body.nodes.addAll(<Node>[foo, bar]);
|
||||
|
||||
test('type-check', () {
|
||||
expect(foo, isUnknownElement);
|
||||
|
|
|
@ -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.
|
||||
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
test('Uri.base', () {
|
||||
expect(Uri.base.scheme, "http");
|
||||
expect(Uri.base.toString(), window.location.href);
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
// 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 web_gl_test;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'dart:html';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:web_gl';
|
||||
import 'dart:web_gl' as gl;
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
// Test that WebGL is present in dart:web_gl API
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
final isRenderingContext = predicate((x) => x is RenderingContext);
|
||||
final isContextAttributes = predicate((x) => x is gl.ContextAttributes);
|
||||
|
||||
main() {
|
||||
group('supported', () {
|
||||
test('supported', () {
|
||||
expect(RenderingContext.supported, isTrue);
|
||||
|
@ -27,7 +27,7 @@ main() {
|
|||
var context = canvas.getContext3d();
|
||||
if (RenderingContext.supported) {
|
||||
expect(context, isNotNull);
|
||||
expect(context, new isInstanceOf<RenderingContext>());
|
||||
expect(context, isRenderingContext);
|
||||
} else {
|
||||
expect(context, isNull);
|
||||
}
|
||||
|
@ -36,7 +36,8 @@ main() {
|
|||
if (RenderingContext.supported) {
|
||||
test('simple', () {
|
||||
var canvas = new CanvasElement();
|
||||
var context = canvas.getContext('experimental-webgl');
|
||||
var context =
|
||||
canvas.getContext('experimental-webgl') as gl.RenderingContext;
|
||||
var shader = context.createShader(gl.VERTEX_SHADER);
|
||||
context.shaderSource(shader, 'void main() { }');
|
||||
context.compileShader(shader);
|
||||
|
@ -48,11 +49,11 @@ main() {
|
|||
var canvas = new CanvasElement();
|
||||
var context = canvas.getContext3d();
|
||||
expect(context, isNotNull);
|
||||
expect(context, new isInstanceOf<RenderingContext>());
|
||||
expect(context, isRenderingContext);
|
||||
|
||||
context = canvas.getContext3d(depth: false);
|
||||
expect(context, isNotNull);
|
||||
expect(context, new isInstanceOf<RenderingContext>());
|
||||
expect(context, isRenderingContext);
|
||||
});
|
||||
|
||||
test('texImage2D', () {
|
||||
|
@ -95,7 +96,7 @@ main() {
|
|||
var attributes = context.getContextAttributes();
|
||||
|
||||
expect(attributes, isNotNull);
|
||||
expect(attributes, new isInstanceOf<gl.ContextAttributes>());
|
||||
expect(attributes, isContextAttributes);
|
||||
|
||||
expect(attributes.alpha, isBoolean);
|
||||
expect(attributes.antialias, isBoolean);
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
library WindowEqualityTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
var obfuscated = null;
|
||||
|
||||
test('notNull', () {
|
||||
expect(window, isNotNull);
|
||||
expect(window, isNot(equals(obfuscated)));
|
||||
expect(window != obfuscated, isTrue);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
// 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 WindowManglingTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html' as dom;
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
// Defined in dom.Window.
|
||||
get navigator => "Dummy";
|
||||
|
||||
|
@ -14,13 +13,12 @@ $eq(x, y) => false;
|
|||
$eq$(x, y) => false;
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
var win = dom.window;
|
||||
|
||||
test('windowMethod', () {
|
||||
final message = navigator;
|
||||
final x = win.navigator;
|
||||
expect(x, isNot(equals(message)));
|
||||
expect(x, notEquals(message));
|
||||
});
|
||||
|
||||
test('windowEquals', () {
|
||||
|
|
|
@ -2,12 +2,10 @@
|
|||
// 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 WindowNSMETest;
|
||||
import "package:expect/expect.dart";
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html' as dom;
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
// Not defined in dom.Window.
|
||||
foo(x) => x;
|
||||
|
||||
|
@ -18,20 +16,12 @@ class Unused {
|
|||
int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1));
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
var things = [new Unused(), dom.window];
|
||||
var things = <dynamic>[new Unused(), dom.window];
|
||||
|
||||
test('windowNonMethod', () {
|
||||
var win = things[inscrutable(1)];
|
||||
final message = foo("Hello World");
|
||||
try {
|
||||
String x = win.foo(message);
|
||||
expect(false, isTrue, reason: 'Should not reach here: $x');
|
||||
} on NoSuchMethodError catch (e) {
|
||||
// Expected exception.
|
||||
} on Exception catch (e) {
|
||||
expect(false, isTrue, reason: 'Wrong exception: $e');
|
||||
}
|
||||
expect(() => win.foo(message), throwsNoSuchMethodError);
|
||||
});
|
||||
|
||||
test('foo', () {
|
||||
|
@ -40,16 +30,10 @@ main() {
|
|||
expect(x, 'not bar');
|
||||
});
|
||||
|
||||
// Use dom.window direclty in case the compiler does type inference.
|
||||
// Use dom.window directly in case the compiler does type inference.
|
||||
test('windowNonMethod2', () {
|
||||
final message = foo("Hello World");
|
||||
try {
|
||||
String x = dom.window.foo(message);
|
||||
expect(false, isTrue, reason: 'Should not reach here: $x');
|
||||
} on NoSuchMethodError catch (e) {
|
||||
// Expected exception.
|
||||
} on Exception catch (e) {
|
||||
expect(false, isTrue, reason: 'Wrong exception: $e');
|
||||
}
|
||||
expect(() => (dom.window as dynamic).foo(message),
|
||||
throwsNoSuchMethodError);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,14 +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.
|
||||
|
||||
library WindowTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
test('scrollXY', () {
|
||||
expect(window.scrollX, 0);
|
||||
expect(window.scrollY, 0);
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
library wrapping_collection_test;
|
||||
|
||||
import 'dart:html';
|
||||
import 'dart:html_common';
|
||||
import 'dart:js' as js;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
/// Test that if we access objects through JS-interop we get the
|
||||
/// appropriate objects, even if dart:html maps them.
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
library XSLTProcessorTest;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
main() {
|
||||
|
||||
useHtmlIndividualConfiguration();
|
||||
|
||||
group('supported', () {
|
||||
test('supported', () {
|
||||
expect(XsltProcessor.supported, true);
|
||||
|
|
|
@ -2436,21 +2436,11 @@ final notYetStrongTests = new HashSet<String>.from([
|
|||
'lib/html/js_typed_interop_side_cast_exp_test',
|
||||
'lib/html/js_typed_interop_side_cast_test',
|
||||
'lib/html/keyboard_event_test',
|
||||
'lib/html/localstorage_test',
|
||||
'lib/html/mutationobserver_test',
|
||||
'lib/html/node_test',
|
||||
'lib/html/node_validator_important_if_you_suppress_make_the_bug_critical_test',
|
||||
'lib/html/postmessage_structured_test',
|
||||
'lib/html/queryall_test',
|
||||
'lib/html/resource_http_test',
|
||||
'lib/html/selectelement_test',
|
||||
'lib/html/track_element_constructor_test',
|
||||
'lib/html/transferables_test',
|
||||
'lib/html/typed_arrays_range_checks_test',
|
||||
'lib/html/typing_test',
|
||||
'lib/html/unknownelement_test',
|
||||
'lib/html/webgl_1_test',
|
||||
'lib/html/window_nosuchmethod_test',
|
||||
'lib/html/wrapping_collections_test',
|
||||
// TODO(jmesserly): these are both under "dart:html" as well.
|
||||
'js_test',
|
||||
|
|
|
@ -161,6 +161,20 @@ Object same(Object value) => new _Expectation((actual) {
|
|||
Expect.identical(value, actual);
|
||||
});
|
||||
|
||||
Object closeTo(num value, num tolerance) => new _Expectation((actual) {
|
||||
Expect.approxEquals(value, actual, tolerance);
|
||||
});
|
||||
|
||||
/// Succeeds if the actual value is any of the given strings. Unlike matcher's
|
||||
/// [anyOf], this only works with strings and requires an explicit list.
|
||||
Object anyOf(List<String> expected) => new _Expectation((actual) {
|
||||
for (var string in expected) {
|
||||
if (actual == string) return;
|
||||
}
|
||||
|
||||
fail("Expected $actual to be one of $expected.");
|
||||
});
|
||||
|
||||
/// One level of group() nesting to track an optional [setUp()] and [tearDown()]
|
||||
/// function for the group.
|
||||
///
|
||||
|
|
Loading…
Reference in a new issue