| 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('DocumentFragmentTest'); | 5 #library('DocumentFragmentTest'); |
| 6 #import('../../lib/unittest/unittest.dart'); | 6 #import('../../lib/unittest/unittest.dart'); |
| 7 #import('../../lib/unittest/html_config.dart'); | 7 #import('../../lib/unittest/html_config.dart'); |
| 8 #import('dart:html'); | 8 #import('dart:html'); |
| 9 #source('util.dart'); | 9 #source('util.dart'); |
| 10 | 10 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 fragment.on.click.add((e) => null); | 283 fragment.on.click.add((e) => null); |
| 284 fragment.blur(); | 284 fragment.blur(); |
| 285 fragment.focus(); | 285 fragment.focus(); |
| 286 fragment.click(); | 286 fragment.click(); |
| 287 fragment.scrollByLines(2); | 287 fragment.scrollByLines(2); |
| 288 fragment.scrollByPages(2); | 288 fragment.scrollByPages(2); |
| 289 fragment.scrollIntoView(); | 289 fragment.scrollIntoView(); |
| 290 fragment.webkitRequestFullScreen(2); | 290 fragment.webkitRequestFullScreen(2); |
| 291 }); | 291 }); |
| 292 | 292 |
| 293 asyncTest('default values', 1, () { | 293 test('default values', () { |
| 294 var fragment = new DocumentFragment(); | 294 var fragment = new DocumentFragment(); |
| 295 fragment.rect.then((ElementRect rect) { | 295 fragment.rect.then(expectAsync1((ElementRect rect) { |
| 296 expectEmptyRect(rect.client); | 296 expectEmptyRect(rect.client); |
| 297 expectEmptyRect(rect.offset); | 297 expectEmptyRect(rect.offset); |
| 298 expectEmptyRect(rect.scroll); | 298 expectEmptyRect(rect.scroll); |
| 299 expectEmptyRect(rect.bounding); | 299 expectEmptyRect(rect.bounding); |
| 300 Expect.isTrue(rect.clientRects.isEmpty()); | 300 Expect.isTrue(rect.clientRects.isEmpty()); |
| 301 callbackDone(); | 301 })); |
| 302 }); | |
| 303 Expect.equals("false", fragment.contentEditable); | 302 Expect.equals("false", fragment.contentEditable); |
| 304 Expect.equals(-1, fragment.tabIndex); | 303 Expect.equals(-1, fragment.tabIndex); |
| 305 Expect.equals("", fragment.id); | 304 Expect.equals("", fragment.id); |
| 306 Expect.equals("", fragment.title); | 305 Expect.equals("", fragment.title); |
| 307 Expect.equals("", fragment.tagName); | 306 Expect.equals("", fragment.tagName); |
| 308 Expect.equals("", fragment.webkitdropzone); | 307 Expect.equals("", fragment.webkitdropzone); |
| 309 Expect.equals("", fragment.webkitRegionOverflow); | 308 Expect.equals("", fragment.webkitRegionOverflow); |
| 310 Expect.isFalse(fragment.isContentEditable); | 309 Expect.isFalse(fragment.isContentEditable); |
| 311 Expect.isFalse(fragment.draggable); | 310 Expect.isFalse(fragment.draggable); |
| 312 Expect.isFalse(fragment.hidden); | 311 Expect.isFalse(fragment.hidden); |
| 313 Expect.isFalse(fragment.spellcheck); | 312 Expect.isFalse(fragment.spellcheck); |
| 314 Expect.isFalse(fragment.translate); | 313 Expect.isFalse(fragment.translate); |
| 315 Expect.isNull(fragment.nextElementSibling); | 314 Expect.isNull(fragment.nextElementSibling); |
| 316 Expect.isNull(fragment.previousElementSibling); | 315 Expect.isNull(fragment.previousElementSibling); |
| 317 Expect.isNull(fragment.offsetParent); | 316 Expect.isNull(fragment.offsetParent); |
| 318 Expect.isNull(fragment.parent); | 317 Expect.isNull(fragment.parent); |
| 319 Expect.isTrue(fragment.attributes.isEmpty()); | 318 Expect.isTrue(fragment.attributes.isEmpty()); |
| 320 Expect.isTrue(fragment.classes.isEmpty()); | 319 Expect.isTrue(fragment.classes.isEmpty()); |
| 321 Expect.isTrue(fragment.dataAttributes.isEmpty()); | 320 Expect.isTrue(fragment.dataAttributes.isEmpty()); |
| 322 Expect.isFalse(fragment.matchesSelector("foo")); | 321 Expect.isFalse(fragment.matchesSelector("foo")); |
| 323 Expect.isFalse(fragment.matchesSelector("*")); | 322 Expect.isFalse(fragment.matchesSelector("*")); |
| 324 }); | 323 }); |
| 325 | 324 |
| 326 asyncTest('style', 1, () { | 325 test('style', () { |
| 327 var fragment = new DocumentFragment(); | 326 var fragment = new DocumentFragment(); |
| 328 var style = fragment.style; | 327 var style = fragment.style; |
| 329 expectEmptyStyleDeclaration(style); | 328 expectEmptyStyleDeclaration(style); |
| 330 fragment.computedStyle.then((computedStyle) { | 329 fragment.computedStyle.then(expectAsync1((computedStyle) { |
| 331 expectEmptyStyleDeclaration(computedStyle); | 330 expectEmptyStyleDeclaration(computedStyle); |
| 332 callbackDone(); | 331 })); |
| 333 }); | |
| 334 }); | 332 }); |
| 335 | 333 |
| 336 // TODO(nweiz): re-enable when const is better supported in dartc and/or frog | 334 // TODO(nweiz): re-enable when const is better supported in dartc and/or frog |
| 337 // test('const fields are immutable', () { | 335 // test('const fields are immutable', () { |
| 338 // var fragment = new DocumentFragment(); | 336 // var fragment = new DocumentFragment(); |
| 339 // assertConstError(() => fragment.attributes['title'] = 'foo'); | 337 // assertConstError(() => fragment.attributes['title'] = 'foo'); |
| 340 // assertConstError(() => fragment.dataAttributes['title'] = 'foo'); | 338 // assertConstError(() => fragment.dataAttributes['title'] = 'foo'); |
| 341 // fragment.rect.then((ElementRect rect) { | 339 // fragment.rect.then((ElementRect rect) { |
| 342 // assertConstError(() => rect.clientRects.add(null)); | 340 // assertConstError(() => rect.clientRects.add(null)); |
| 343 // callbackDone(); | 341 // callbackDone(); |
| 344 // }); | 342 // }); |
| 345 // // Issue 174: #classes is currently not const | 343 // // Issue 174: #classes is currently not const |
| 346 // // assertConstError(() => fragment.classes.add('foo')); | 344 // // assertConstError(() => fragment.classes.add('foo')); |
| 347 // }); | 345 // }); |
| 348 | 346 |
| 349 test('query searches the fragment', () { | 347 test('query searches the fragment', () { |
| 350 var fragment = new DocumentFragment.html( | 348 var fragment = new DocumentFragment.html( |
| 351 "<div class='foo'><a>foo</a><b>bar</b></div>"); | 349 "<div class='foo'><a>foo</a><b>bar</b></div>"); |
| 352 Expect.equals("A", fragment.query(".foo a").tagName); | 350 Expect.equals("A", fragment.query(".foo a").tagName); |
| 353 Expect.listEquals(["A", "B"], _nodeStrings(fragment.queryAll(".foo *"))); | 351 Expect.listEquals(["A", "B"], _nodeStrings(fragment.queryAll(".foo *"))); |
| 354 }); | 352 }); |
| 355 } | 353 } |
| OLD | NEW |