| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library mutationobserver_test; | 5 library mutationobserver_test; |
| 6 |
| 6 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 7 import 'package:unittest/html_individual_config.dart'; | 8 import 'package:unittest/html_individual_config.dart'; |
| 8 import 'dart:html'; | 9 import 'dart:html'; |
| 9 | 10 |
| 10 // Due to https://code.google.com/p/chromium/issues/detail?id=329103 | 11 // Due to https://code.google.com/p/chromium/issues/detail?id=329103 |
| 11 // mutationObservers sometimes do not fire if the node being observed is GCed | 12 // mutationObservers sometimes do not fire if the node being observed is GCed |
| 12 // so we keep around references to all nodes we have created mutation | 13 // so we keep around references to all nodes we have created mutation |
| 13 // observers for. | 14 // observers for. |
| 14 var keepAlive = []; | 15 var keepAlive = []; |
| 15 | 16 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // If it's not supported, don't block waiting for it. | 50 // If it's not supported, don't block waiting for it. |
| 50 if (!MutationObserver.supported) { | 51 if (!MutationObserver.supported) { |
| 51 return () => done; | 52 return () => done; |
| 52 } | 53 } |
| 53 | 54 |
| 54 return expectAsyncUntil(callback, () => done); | 55 return expectAsyncUntil(callback, () => done); |
| 55 } | 56 } |
| 56 | 57 |
| 57 test('empty options is syntax error', () { | 58 test('empty options is syntax error', () { |
| 58 expect(() { | 59 expect(() { |
| 59 var mutationObserver = new MutationObserver( | 60 var mutationObserver = new MutationObserver((mutations, observer) { |
| 60 (mutations, observer) { expect(false, isTrue, | 61 expect(false, isTrue, reason: 'Should not be reached'); |
| 61 reason: 'Should not be reached'); }); | 62 }); |
| 62 expect(() { mutationObserver.observe(document, {}); }, | 63 expect(() { |
| 63 throws); | 64 mutationObserver.observe(document, {}); |
| 65 }, throws); |
| 64 }, expectation); | 66 }, expectation); |
| 65 }); | 67 }); |
| 66 | 68 |
| 67 test('direct-parallel options-named', () { | 69 test('direct-parallel options-named', () { |
| 68 expect(() { | 70 expect(() { |
| 69 var container = new DivElement(); | 71 var container = new DivElement(); |
| 70 keepAlive.add(container); | 72 keepAlive.add(container); |
| 71 var div1 = new DivElement(); | 73 var div1 = new DivElement(); |
| 72 var div2 = new DivElement(); | 74 var div2 = new DivElement(); |
| 73 var mutationObserver = new MutationObserver( | 75 var mutationObserver = new MutationObserver( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 103 var mutationObserver = new MutationObserver( | 105 var mutationObserver = new MutationObserver( |
| 104 mutationCallback(2, orderedEquals([div1, div2]))); | 106 mutationCallback(2, orderedEquals([div1, div2]))); |
| 105 mutationObserver.observe(container, childList: true, subtree: true); | 107 mutationObserver.observe(container, childList: true, subtree: true); |
| 106 | 108 |
| 107 container.append(div1); | 109 container.append(div1); |
| 108 div1.append(div2); | 110 div1.append(div2); |
| 109 }, expectation); | 111 }, expectation); |
| 110 }); | 112 }); |
| 111 }); | 113 }); |
| 112 } | 114 } |
| OLD | NEW |