dart-sdk/tests/lib/html/serialized_script_value_test.dart
Srujan Gaddam a925f4770f [dart:html] Remove 2.7 annotation from lib/html
Strips out the temporary annotation so all the tests without
NNBD related changes can run in strong mode.

Change-Id: I88f18916f0c5a45a80eddb73941db19984f0bfcf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140652
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2020-04-06 20:41:14 +00:00

55 lines
1.6 KiB
Dart

// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:html';
import 'package:expect/minitest.dart';
import 'utils.dart';
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() {
serializationTest('null', null);
serializationTest('int', 1);
serializationTest('double', 2.39);
serializationTest('string', 'hey!');
final simpleMap = {'a': 100, 'b': 's'};
final dagMap = {'x': simpleMap, 'y': simpleMap};
final cyclicMap = {'b': dagMap};
cyclicMap['a'] = cyclicMap;
serializationTest('simple map', simpleMap);
serializationTest('dag map', dagMap);
serializationTest('cyclic map', cyclicMap);
final simpleList = [100, 's'];
final dagList = [simpleList, simpleList];
final cyclicList = [dagList];
cyclicList.add(cyclicList);
serializationTest('simple list', simpleList);
serializationTest('dag list', dagList);
serializationTest('cyclic list', cyclicList);
serializationTest('datetime', [new DateTime.now()]);
var blob = new Blob(
['Indescribable... Indestructible! Nothing can stop it!'], 'text/plain');
serializationTest('blob', [blob]);
var canvas = new CanvasElement();
canvas.width = 100;
canvas.height = 100;
var imageData = canvas.context2D.getImageData(0, 0, 1, 1);
serializationTest('imagedata', [imageData]);
}