| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 created_callback_test; | 5 library created_callback_test; |
| 6 import 'package:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
| 7 import 'package:unittest/html_config.dart'; | 7 import 'package:unittest/html_config.dart'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'dart:js' as js; | 9 import 'dart:js' as js; |
| 10 import '../utils.dart'; | 10 import '../utils.dart'; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 expect(ErrorConstructorElement.callCount, 1); | 141 expect(ErrorConstructorElement.callCount, 1); |
| 142 | 142 |
| 143 var e = dummy.firstChild; | 143 var e = dummy.firstChild; |
| 144 // Accessing should not re-run the constructor. | 144 // Accessing should not re-run the constructor. |
| 145 expect(ErrorConstructorElement.callCount, 1); | 145 expect(ErrorConstructorElement.callCount, 1); |
| 146 expect(e is HtmlElement, isTrue); | 146 expect(e is HtmlElement, isTrue); |
| 147 expect(e is ErrorConstructorElement, isFalse); | 147 expect(e is ErrorConstructorElement, isFalse); |
| 148 }); | 148 }); |
| 149 | 149 |
| 150 // Issue - 13711 Need to fix the handling of the created constructor. | 150 test('created cannot be called from nested constructor', |
| 151 // test('created cannot be called from nested constructor', | 151 NestedCreatedConstructorElement.test); |
| 152 // NestedCreatedConstructorElement.test); | |
| 153 | 152 |
| 154 | 153 |
| 155 // TODO(vsm): Port additional test from upstream here: | 154 // TODO(vsm): Port additional test from upstream here: |
| 156 // http://src.chromium.org/viewvc/blink/trunk/LayoutTests/fast/dom/custom/crea
ted-callback.html?r1=156141&r2=156185 | 155 // http://src.chromium.org/viewvc/blink/trunk/LayoutTests/fast/dom/custom/crea
ted-callback.html?r1=156141&r2=156185 |
| 157 } | 156 } |
| 158 | 157 |
| 159 | 158 |
| 160 class NestedElement extends HtmlElement { | 159 class NestedElement extends HtmlElement { |
| 161 static final tag = 'x-nested'; | 160 static final tag = 'x-nested'; |
| 162 | 161 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 static constructB() { | 255 static constructB() { |
| 257 // This should throw an exception. | 256 // This should throw an exception. |
| 258 constructedB = new B.created(); | 257 constructedB = new B.created(); |
| 259 return constructedB; | 258 return constructedB; |
| 260 } | 259 } |
| 261 | 260 |
| 262 static void test() { | 261 static void test() { |
| 263 register(); | 262 register(); |
| 264 | 263 |
| 265 // Exception should have occurred on upgrade. | 264 // Exception should have occurred on upgrade. |
| 266 var e = new Element.tag(tag); | 265 var e; |
| 266 expectGlobalError(() { |
| 267 e = new Element.tag(tag); |
| 268 }); |
| 267 expect(e is NestedCreatedConstructorElement, isFalse); | 269 expect(e is NestedCreatedConstructorElement, isFalse); |
| 268 expect(e is HtmlElement, isTrue); | 270 expect(e is HtmlElement, isTrue); |
| 269 // Should not have been set. | 271 // Should not have been set. |
| 270 expect(constructedB, isNull); | 272 expect(constructedB, isNull); |
| 271 } | 273 } |
| 272 } | 274 } |
| 273 | 275 |
| 274 void expectGlobalError(Function test) { | 276 void expectGlobalError(Function test) { |
| 275 js.context['testExpectsGlobalError'] = true; | 277 js.context['testExpectsGlobalError'] = true; |
| 276 try { | 278 try { |
| 277 test(); | 279 test(); |
| 278 } catch(e) { | 280 } catch(e) { |
| 279 rethrow; | 281 rethrow; |
| 280 } finally { | 282 } finally { |
| 281 js.context['testExpectsGlobalError'] = false; | 283 js.context['testExpectsGlobalError'] = false; |
| 282 } | 284 } |
| 283 var errors = js.context['testSuppressedGlobalErrors']; | 285 var errors = js.context['testSuppressedGlobalErrors']; |
| 284 expect(errors['length'], 1); | 286 expect(errors['length'], 1); |
| 285 // Clear out the errors; | 287 // Clear out the errors; |
| 286 js.context['testSuppressedGlobalErrors']['length'] = 0; | 288 js.context['testSuppressedGlobalErrors']['length'] = 0; |
| 287 } | 289 } |
| OLD | NEW |