| 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('../../pkg/unittest/unittest.dart'); | 6 #import('../../pkg/unittest/unittest.dart'); |
| 7 #import('../../pkg/unittest/html_config.dart'); | 7 #import('../../pkg/unittest/html_config.dart'); |
| 8 #import('dart:html'); | 8 #import('dart:html'); |
| 9 #source('util.dart'); | 9 #source('util.dart'); |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 assertConstError(void fn()) { | 27 assertConstError(void fn()) { |
| 28 try { | 28 try { |
| 29 fn(); | 29 fn(); |
| 30 } catch (e) { | 30 } catch (e) { |
| 31 if (e is UnsupportedError) { | 31 if (e is UnsupportedError) { |
| 32 return; | 32 return; |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 Expect.fail('Expected immutability error'); | 35 expect(true, isFalse, reason: 'Expected immutability error'); |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 void expectEmptyStyleDeclaration(CSSStyleDeclaration style) { | 38 void expectEmptyStyleDeclaration(CSSStyleDeclaration style) { |
| 39 Expect.equals("", style.cssText); | 39 expect(style.cssText, equals('')); |
| 40 Expect.equals("", style.getPropertyPriority('color')); | 40 expect(style.getPropertyPriority('color'), equals('')); |
| 41 Expect.equals("", style.item(0)); | 41 expect(style.item(0), equals('')); |
| 42 Expect.equals(0, style.length); | 42 expect(style.length, isZero); |
| 43 // TODO(jacobr): these checks throw NotImplementedExceptions in dartium. | 43 // TODO(jacobr): these checks throw NotImplementedExceptions in dartium. |
| 44 // Expect.isNull(style.parentRule); | 44 // expect(style.parentRule, isNull); |
| 45 // Expect.isNull(style.getPropertyCSSValue('color')); | 45 // expect(style.getPropertyCSSValue('color'), isNull); |
| 46 // Expect.isNull(style.getPropertyShorthand('color')); | 46 // expect(style.getPropertyShorthand('color'), isNull); |
| 47 // Expect.isFalse(style.isPropertyImplicit('color')); | 47 // expect(style.isPropertyImplicit('color'), isFalse); |
| 48 | 48 |
| 49 // Ideally these would throw errors, but it's not possible to create a class | 49 // Ideally these would throw errors, but it's not possible to create a class |
| 50 // that'll intercept these calls without implementing the entire | 50 // that'll intercept these calls without implementing the entire |
| 51 // CSSStyleDeclaration interface, so we'll settle for them being no-ops. | 51 // CSSStyleDeclaration interface, so we'll settle for them being no-ops. |
| 52 style.cssText = '* {color: blue}'; | 52 style.cssText = '* {color: blue}'; |
| 53 style.removeProperty('color'); | 53 style.removeProperty('color'); |
| 54 style.setProperty('color', 'blue'); | 54 style.setProperty('color', 'blue'); |
| 55 } | 55 } |
| 56 | 56 |
| 57 group('constructors', () { | 57 group('constructors', () { |
| 58 test('0-argument makes an empty fragment', () { | 58 test('0-argument makes an empty fragment', () { |
| 59 final fragment = new DocumentFragment(); | 59 final fragment = new DocumentFragment(); |
| 60 Expect.listEquals([], fragment.elements); | 60 expect(fragment.elements, equals([])); |
| 61 }); | 61 }); |
| 62 | 62 |
| 63 test('.html parses input as HTML', () { | 63 test('.html parses input as HTML', () { |
| 64 final fragment = new DocumentFragment.html('<a>foo</a>'); | 64 final fragment = new DocumentFragment.html('<a>foo</a>'); |
| 65 Expect.isTrue(fragment.elements[0] is AnchorElement); | 65 expect(fragment.elements[0], |
| 66 new isInstanceOf<AnchorElement>('AnchorElement')); |
| 66 }); | 67 }); |
| 67 | 68 |
| 68 // test('.svg parses input as SVG', () { | 69 // test('.svg parses input as SVG', () { |
| 69 // final fragment = new DocumentFragment.svg('<a>foo</a>'); | 70 // final fragment = new DocumentFragment.svg('<a>foo</a>'); |
| 70 // Expect.isTrue(fragment.elements[0] is SVGAElement); | 71 // expect(fragment.elements[0] is SVGAElement, isTrue); |
| 71 // }); | 72 // }); |
| 72 | 73 |
| 73 // TODO(nweiz): enable this once XML is ported. | 74 // TODO(nweiz): enable this once XML is ported. |
| 74 // test('.xml parses input as XML', () { | 75 // test('.xml parses input as XML', () { |
| 75 // final fragment = new DocumentFragment.xml('<a>foo</a>'); | 76 // final fragment = new DocumentFragment.xml('<a>foo</a>'); |
| 76 // Expect.isTrue(fragment.elements[0] is XMLElement); | 77 // expect(fragment.elements[0] is XMLElement, isTrue); |
| 77 // }); | 78 // }); |
| 78 }); | 79 }); |
| 79 | 80 |
| 80 test('Unsupported operations throw errors', () { | 81 test('Unsupported operations throw errors', () { |
| 81 var emptyFragment = new DocumentFragment(); | 82 var emptyFragment = new DocumentFragment(); |
| 82 expectUnsupported(() => emptyFragment.attributes = {}); | 83 expectUnsupported(() => emptyFragment.attributes = {}); |
| 83 expectUnsupported(() => emptyFragment.classes = []); | 84 expectUnsupported(() => emptyFragment.classes = []); |
| 84 expectUnsupported(() => emptyFragment.classes.add('foo')); | 85 expectUnsupported(() => emptyFragment.classes.add('foo')); |
| 85 expectUnsupported(() => emptyFragment.dataAttributes = {}); | 86 expectUnsupported(() => emptyFragment.dataAttributes = {}); |
| 86 expectUnsupported(() => emptyFragment.contentEditable = "true"); | 87 expectUnsupported(() => emptyFragment.contentEditable = "true"); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 109 fragment = new DocumentFragment(); | 110 fragment = new DocumentFragment(); |
| 110 elements = fragment.elements; | 111 elements = fragment.elements; |
| 111 fragment.nodes.addAll( | 112 fragment.nodes.addAll( |
| 112 [new Text("1"), new Element.tag("A"), new Element.tag("B"), | 113 [new Text("1"), new Element.tag("A"), new Element.tag("B"), |
| 113 new Text("2"), new Element.tag("I"), new Text("3"), | 114 new Text("2"), new Element.tag("I"), new Text("3"), |
| 114 new Element.tag("U")]); | 115 new Element.tag("U")]); |
| 115 }; | 116 }; |
| 116 | 117 |
| 117 test('is initially empty', () { | 118 test('is initially empty', () { |
| 118 elements = new DocumentFragment().elements; | 119 elements = new DocumentFragment().elements; |
| 119 Expect.listEquals([], elements); | 120 expect(elements, equals([])); |
| 120 Expect.isTrue(elements.isEmpty); | 121 expect(elements.isEmpty, isTrue); |
| 121 }); | 122 }); |
| 122 | 123 |
| 123 test('filters out non-element nodes', () { | 124 test('filters out non-element nodes', () { |
| 124 init(); | 125 init(); |
| 125 Expect.listEquals(["1", "A", "B", "2", "I", "3", "U"], | 126 expect(_nodeStrings(fragment.nodes), |
| 126 _nodeStrings(fragment.nodes)); | 127 orderedEquals(["1", "A", "B", "2", "I", "3", "U"])); |
| 127 Expect.listEquals(["A", "B", "I", "U"], _nodeStrings(elements)); | 128 expect(_nodeStrings(elements), |
| 129 orderedEquals(["A", "B", "I", "U"])); |
| 128 }); | 130 }); |
| 129 | 131 |
| 130 test('only indexes elements, not other nodes', () { | 132 test('only indexes elements, not other nodes', () { |
| 131 init(); | 133 init(); |
| 132 elements[1] = new Element.tag("BR"); | 134 elements[1] = new Element.tag("BR"); |
| 133 Expect.listEquals(["1", "A", "BR", "2", "I", "3", "U"], | 135 expect(_nodeStrings(fragment.nodes), |
| 134 _nodeStrings(fragment.nodes)); | 136 orderedEquals(["1", "A", "BR", "2", "I", "3", "U"])); |
| 135 Expect.listEquals(["A", "BR", "I", "U"], _nodeStrings(elements)); | 137 expect(_nodeStrings(elements), |
| 138 orderedEquals(["A", "BR", "I", "U"])); |
| 136 }); | 139 }); |
| 137 | 140 |
| 138 test('adds to both elements and nodes', () { | 141 test('adds to both elements and nodes', () { |
| 139 init(); | 142 init(); |
| 140 elements.add(new Element.tag("UL")); | 143 elements.add(new Element.tag("UL")); |
| 141 Expect.listEquals(["1", "A", "B", "2", "I", "3", "U", "UL"], | 144 expect(_nodeStrings(fragment.nodes), |
| 142 _nodeStrings(fragment.nodes)); | 145 orderedEquals(["1", "A", "B", "2", "I", "3", "U", "UL"])); |
| 143 Expect.listEquals(["A", "B", "I", "U", "UL"], _nodeStrings(elements)); | 146 expect(_nodeStrings(elements), |
| 147 orderedEquals(["A", "B", "I", "U", "UL"])); |
| 144 }); | 148 }); |
| 145 | 149 |
| 146 test('removes only elements, from both elements and nodes', () { | 150 test('removes only elements, from both elements and nodes', () { |
| 147 init(); | 151 init(); |
| 148 Expect.equals("U", elements.removeLast().tagName); | 152 expect(elements.removeLast().tagName, equals('U')); |
| 149 Expect.listEquals(["1", "A", "B", "2", "I", "3"], | 153 expect(_nodeStrings(fragment.nodes), |
| 150 _nodeStrings(fragment.nodes)); | 154 orderedEquals(["1", "A", "B", "2", "I", "3"])); |
| 151 Expect.listEquals(["A", "B", "I"], _nodeStrings(elements)); | 155 expect(_nodeStrings(elements), |
| 156 orderedEquals(["A", "B", "I"])); |
| 152 | 157 |
| 153 Expect.equals("I", elements.removeLast().tagName); | 158 expect(elements.removeLast().tagName, "I"); |
| 154 Expect.listEquals(["1", "A", "B", "2", "3"], | 159 expect(_nodeStrings(fragment.nodes), |
| 155 _nodeStrings(fragment.nodes)); | 160 equals(["1", "A", "B", "2", "3"])); |
| 156 Expect.listEquals(["A", "B"], _nodeStrings(elements)); | 161 expect(_nodeStrings(elements), equals(["A", "B"])); |
| 157 }); | 162 }); |
| 158 | 163 |
| 159 test('accessors are wrapped', () { | 164 test('accessors are wrapped', () { |
| 160 init(); | 165 init(); |
| 161 Expect.equals("A", elements[0].tagName); | 166 expect(elements[0].tagName, "A"); |
| 162 Expect.listEquals( | 167 expect(_nodeStrings(elements.filter((e) => e.tagName == "I")), ["I"]); |
| 163 ["I"], _nodeStrings(elements.filter((e) => e.tagName == "I"))); | 168 expect(elements.every((e) => e is Element), isTrue); |
| 164 Expect.isTrue(elements.every((e) => e is Element)); | 169 expect(elements.some((e) => e.tagName == "U"), isTrue); |
| 165 Expect.isTrue(elements.some((e) => e.tagName == "U")); | 170 expect(elements.isEmpty, isFalse); |
| 166 Expect.isFalse(elements.isEmpty); | 171 expect(elements.length, 4); |
| 167 Expect.equals(4, elements.length); | 172 expect(elements[2].tagName, "I"); |
| 168 Expect.equals("I", elements[2].tagName); | 173 expect(elements.last.tagName, "U"); |
| 169 Expect.equals("U", elements.last.tagName); | |
| 170 }); | 174 }); |
| 171 | 175 |
| 172 test('setting elements overwrites nodes as well', () { | 176 test('setting elements overwrites nodes as well', () { |
| 173 init(); | 177 init(); |
| 174 fragment.elements = [new Element.tag("DIV"), new Element.tag("HEAD")]; | 178 fragment.elements = [new Element.tag("DIV"), new Element.tag("HEAD")]; |
| 175 Expect.listEquals(["DIV", "HEAD"], _nodeStrings(fragment.nodes)); | 179 expect(_nodeStrings(fragment.nodes), equals(["DIV", "HEAD"])); |
| 176 }); | 180 }); |
| 177 }); | 181 }); |
| 178 | 182 |
| 179 test('setting innerHTML works', () { | 183 test('setting innerHTML works', () { |
| 180 var fragment = new DocumentFragment(); | 184 var fragment = new DocumentFragment(); |
| 181 fragment.nodes.add(new Text("foo")); | 185 fragment.nodes.add(new Text("foo")); |
| 182 fragment.innerHTML = "<a>bar</a>baz"; | 186 fragment.innerHTML = "<a>bar</a>baz"; |
| 183 Expect.listEquals(["A", "baz"], _nodeStrings(fragment.nodes)); | 187 expect(_nodeStrings(fragment.nodes), equals(["A", "baz"])); |
| 184 }); | 188 }); |
| 185 | 189 |
| 186 test('getting innerHTML works', () { | 190 test('getting innerHTML works', () { |
| 187 var fragment = new DocumentFragment(); | 191 var fragment = new DocumentFragment(); |
| 188 fragment.nodes.addAll([new Text("foo"), new Element.html("<A>bar</A>")]); | 192 fragment.nodes.addAll([new Text("foo"), new Element.html("<A>bar</A>")]); |
| 189 Expect.equals("foo<a>bar</a>", fragment.innerHTML); | 193 expect(fragment.innerHTML, "foo<a>bar</a>"); |
| 190 Expect.equals("foo<a>bar</a>", fragment.outerHTML); | 194 expect(fragment.outerHTML, "foo<a>bar</a>"); |
| 191 }); | 195 }); |
| 192 | 196 |
| 193 group('insertAdjacentElement', () { | 197 group('insertAdjacentElement', () { |
| 194 getFragment() => new DocumentFragment.html("<a>foo</a>"); | 198 getFragment() => new DocumentFragment.html("<a>foo</a>"); |
| 195 | 199 |
| 196 test('beforeBegin does nothing', () { | 200 test('beforeBegin does nothing', () { |
| 197 var fragment = getFragment(); | 201 var fragment = getFragment(); |
| 198 Expect.isNull( | 202 expect(fragment.insertAdjacentElement("beforeBegin", |
| 199 fragment.insertAdjacentElement("beforeBegin", new Element.tag("b"))); | 203 new Element.tag("b")), isNull); |
| 200 Expect.equals("<a>foo</a>", fragment.innerHTML); | 204 expect(fragment.innerHTML, "<a>foo</a>"); |
| 201 }); | 205 }); |
| 202 | 206 |
| 203 test('afterEnd does nothing', () { | 207 test('afterEnd does nothing', () { |
| 204 var fragment = getFragment(); | 208 var fragment = getFragment(); |
| 205 Expect.isNull( | 209 expect(fragment.insertAdjacentElement("afterEnd", |
| 206 fragment.insertAdjacentElement("afterEnd", new Element.tag("b"))); | 210 new Element.tag("b")), isNull); |
| 207 Expect.equals("<a>foo</a>", fragment.innerHTML); | 211 expect(fragment.innerHTML, "<a>foo</a>"); |
| 208 }); | 212 }); |
| 209 | 213 |
| 210 test('afterBegin inserts the element', () { | 214 test('afterBegin inserts the element', () { |
| 211 var fragment = getFragment(); | 215 var fragment = getFragment(); |
| 212 var el = new Element.tag("b"); | 216 var el = new Element.tag("b"); |
| 213 Expect.equals(el, fragment.insertAdjacentElement("afterBegin", el)); | 217 expect(fragment.insertAdjacentElement("afterBegin", el), equals(el)); |
| 214 Expect.equals("<b></b><a>foo</a>", fragment.innerHTML); | 218 expect(fragment.innerHTML, "<b></b><a>foo</a>"); |
| 215 }); | 219 }); |
| 216 | 220 |
| 217 test('beforeEnd inserts the element', () { | 221 test('beforeEnd inserts the element', () { |
| 218 var fragment = getFragment(); | 222 var fragment = getFragment(); |
| 219 var el = new Element.tag("b"); | 223 var el = new Element.tag("b"); |
| 220 Expect.equals(el, fragment.insertAdjacentElement("beforeEnd", el)); | 224 expect(fragment.insertAdjacentElement("beforeEnd", el), equals(el)); |
| 221 Expect.equals("<a>foo</a><b></b>", fragment.innerHTML); | 225 expect(fragment.innerHTML, "<a>foo</a><b></b>"); |
| 222 }); | 226 }); |
| 223 }); | 227 }); |
| 224 | 228 |
| 225 group('insertAdjacentText', () { | 229 group('insertAdjacentText', () { |
| 226 getFragment() => new DocumentFragment.html("<a>foo</a>"); | 230 getFragment() => new DocumentFragment.html("<a>foo</a>"); |
| 227 | 231 |
| 228 test('beforeBegin does nothing', () { | 232 test('beforeBegin does nothing', () { |
| 229 var fragment = getFragment(); | 233 var fragment = getFragment(); |
| 230 fragment.insertAdjacentText("beforeBegin", "foo"); | 234 fragment.insertAdjacentText("beforeBegin", "foo"); |
| 231 Expect.equals("<a>foo</a>", fragment.innerHTML); | 235 expect(fragment.innerHTML, "<a>foo</a>"); |
| 232 }); | 236 }); |
| 233 | 237 |
| 234 test('afterEnd does nothing', () { | 238 test('afterEnd does nothing', () { |
| 235 var fragment = getFragment(); | 239 var fragment = getFragment(); |
| 236 fragment.insertAdjacentText("afterEnd", "foo"); | 240 fragment.insertAdjacentText("afterEnd", "foo"); |
| 237 Expect.equals("<a>foo</a>", fragment.innerHTML); | 241 expect(fragment.innerHTML, "<a>foo</a>"); |
| 238 }); | 242 }); |
| 239 | 243 |
| 240 test('afterBegin inserts the text', () { | 244 test('afterBegin inserts the text', () { |
| 241 var fragment = getFragment(); | 245 var fragment = getFragment(); |
| 242 fragment.insertAdjacentText("afterBegin", "foo"); | 246 fragment.insertAdjacentText("afterBegin", "foo"); |
| 243 Expect.equals("foo<a>foo</a>", fragment.innerHTML); | 247 expect(fragment.innerHTML, "foo<a>foo</a>"); |
| 244 }); | 248 }); |
| 245 | 249 |
| 246 test('beforeEnd inserts the text', () { | 250 test('beforeEnd inserts the text', () { |
| 247 var fragment = getFragment(); | 251 var fragment = getFragment(); |
| 248 fragment.insertAdjacentText("beforeEnd", "foo"); | 252 fragment.insertAdjacentText("beforeEnd", "foo"); |
| 249 Expect.equals("<a>foo</a>foo", fragment.innerHTML); | 253 expect(fragment.innerHTML, "<a>foo</a>foo"); |
| 250 }); | 254 }); |
| 251 }); | 255 }); |
| 252 | 256 |
| 253 group('insertAdjacentHTML', () { | 257 group('insertAdjacentHTML', () { |
| 254 getFragment() => new DocumentFragment.html("<a>foo</a>"); | 258 getFragment() => new DocumentFragment.html("<a>foo</a>"); |
| 255 | 259 |
| 256 test('beforeBegin does nothing', () { | 260 test('beforeBegin does nothing', () { |
| 257 var fragment = getFragment(); | 261 var fragment = getFragment(); |
| 258 fragment.insertAdjacentHTML("beforeBegin", "foo<br>"); | 262 fragment.insertAdjacentHTML("beforeBegin", "foo<br>"); |
| 259 Expect.equals("<a>foo</a>", fragment.innerHTML); | 263 expect(fragment.innerHTML, "<a>foo</a>"); |
| 260 }); | 264 }); |
| 261 | 265 |
| 262 test('afterEnd does nothing', () { | 266 test('afterEnd does nothing', () { |
| 263 var fragment = getFragment(); | 267 var fragment = getFragment(); |
| 264 fragment.insertAdjacentHTML("afterEnd", "<br>foo"); | 268 fragment.insertAdjacentHTML("afterEnd", "<br>foo"); |
| 265 Expect.equals("<a>foo</a>", fragment.innerHTML); | 269 expect(fragment.innerHTML, "<a>foo</a>"); |
| 266 }); | 270 }); |
| 267 | 271 |
| 268 test('afterBegin inserts the HTML', () { | 272 test('afterBegin inserts the HTML', () { |
| 269 var fragment = getFragment(); | 273 var fragment = getFragment(); |
| 270 fragment.insertAdjacentHTML("afterBegin", "foo<br>"); | 274 fragment.insertAdjacentHTML("afterBegin", "foo<br>"); |
| 271 Expect.equals("foo<br><a>foo</a>", fragment.innerHTML); | 275 expect(fragment.innerHTML, "foo<br><a>foo</a>"); |
| 272 }); | 276 }); |
| 273 | 277 |
| 274 test('beforeEnd inserts the HTML', () { | 278 test('beforeEnd inserts the HTML', () { |
| 275 var fragment = getFragment(); | 279 var fragment = getFragment(); |
| 276 fragment.insertAdjacentHTML("beforeEnd", "<br>foo"); | 280 fragment.insertAdjacentHTML("beforeEnd", "<br>foo"); |
| 277 Expect.equals("<a>foo</a><br>foo", fragment.innerHTML); | 281 expect(fragment.innerHTML, "<a>foo</a><br>foo"); |
| 278 }); | 282 }); |
| 279 }); | 283 }); |
| 280 | 284 |
| 281 // Just test that these methods don't throw errors | 285 // Just test that these methods don't throw errors |
| 282 test("no-op methods don't throw errors", () { | 286 test("no-op methods don't throw errors", () { |
| 283 var fragment = new DocumentFragment(); | 287 var fragment = new DocumentFragment(); |
| 284 fragment.on.click.add((e) => null); | 288 fragment.on.click.add((e) => null); |
| 285 fragment.blur(); | 289 fragment.blur(); |
| 286 fragment.focus(); | 290 fragment.focus(); |
| 287 fragment.click(); | 291 fragment.click(); |
| 288 fragment.scrollByLines(2); | 292 fragment.scrollByLines(2); |
| 289 fragment.scrollByPages(2); | 293 fragment.scrollByPages(2); |
| 290 fragment.scrollIntoView(); | 294 fragment.scrollIntoView(); |
| 291 fragment.webkitRequestFullScreen(2); | 295 fragment.webkitRequestFullScreen(2); |
| 292 }); | 296 }); |
| 293 | 297 |
| 294 test('default values', () { | 298 test('default values', () { |
| 295 var fragment = new DocumentFragment(); | 299 var fragment = new DocumentFragment(); |
| 296 fragment.rect.then(expectAsync1((ElementRect rect) { | 300 fragment.rect.then(expectAsync1((ElementRect rect) { |
| 297 expectEmptyRect(rect.client); | 301 expectEmptyRect(rect.client); |
| 298 expectEmptyRect(rect.offset); | 302 expectEmptyRect(rect.offset); |
| 299 expectEmptyRect(rect.scroll); | 303 expectEmptyRect(rect.scroll); |
| 300 expectEmptyRect(rect.bounding); | 304 expectEmptyRect(rect.bounding); |
| 301 Expect.isTrue(rect.clientRects.isEmpty); | 305 expect(rect.clientRects.isEmpty, isTrue); |
| 302 })); | 306 })); |
| 303 Expect.equals("false", fragment.contentEditable); | 307 expect(fragment.contentEditable, "false"); |
| 304 Expect.equals(-1, fragment.tabIndex); | 308 expect(fragment.tabIndex, -1); |
| 305 Expect.equals("", fragment.id); | 309 expect(fragment.id, ""); |
| 306 Expect.equals("", fragment.title); | 310 expect(fragment.title, ""); |
| 307 Expect.equals("", fragment.tagName); | 311 expect(fragment.tagName, ""); |
| 308 Expect.equals("", fragment.webkitdropzone); | 312 expect(fragment.webkitdropzone, ""); |
| 309 Expect.equals("", fragment.webkitRegionOverflow); | 313 expect(fragment.webkitRegionOverflow, ""); |
| 310 Expect.isFalse(fragment.isContentEditable); | 314 expect(fragment.isContentEditable, isFalse); |
| 311 Expect.isFalse(fragment.draggable); | 315 expect(fragment.draggable, isFalse); |
| 312 Expect.isFalse(fragment.hidden); | 316 expect(fragment.hidden, isFalse); |
| 313 Expect.isFalse(fragment.spellcheck); | 317 expect(fragment.spellcheck, isFalse); |
| 314 Expect.isFalse(fragment.translate); | 318 expect(fragment.translate, isFalse); |
| 315 Expect.isNull(fragment.nextElementSibling); | 319 expect(fragment.nextElementSibling, isNull); |
| 316 Expect.isNull(fragment.previousElementSibling); | 320 expect(fragment.previousElementSibling, isNull); |
| 317 Expect.isNull(fragment.offsetParent); | 321 expect(fragment.offsetParent, isNull); |
| 318 Expect.isNull(fragment.parent); | 322 expect(fragment.parent, isNull); |
| 319 Expect.isTrue(fragment.attributes.isEmpty); | 323 expect(fragment.attributes.isEmpty, isTrue); |
| 320 Expect.isTrue(fragment.classes.isEmpty); | 324 expect(fragment.classes.isEmpty, isTrue); |
| 321 Expect.isTrue(fragment.dataAttributes.isEmpty); | 325 expect(fragment.dataAttributes.isEmpty, isTrue); |
| 322 Expect.isFalse(fragment.matchesSelector("foo")); | 326 expect(fragment.matchesSelector("foo"), isFalse); |
| 323 Expect.isFalse(fragment.matchesSelector("*")); | 327 expect(fragment.matchesSelector("*"), isFalse); |
| 324 }); | 328 }); |
| 325 | 329 |
| 326 test('style', () { | 330 test('style', () { |
| 327 var fragment = new DocumentFragment(); | 331 var fragment = new DocumentFragment(); |
| 328 var style = fragment.style; | 332 var style = fragment.style; |
| 329 expectEmptyStyleDeclaration(style); | 333 expectEmptyStyleDeclaration(style); |
| 330 fragment.computedStyle.then(expectAsync1((computedStyle) { | 334 fragment.computedStyle.then(expectAsync1((computedStyle) { |
| 331 expectEmptyStyleDeclaration(computedStyle); | 335 expectEmptyStyleDeclaration(computedStyle); |
| 332 })); | 336 })); |
| 333 }); | 337 }); |
| 334 | 338 |
| 335 // TODO(nweiz): re-enable when const is better supported in dartc and/or frog | 339 // TODO(nweiz): re-enable when const is better supported in dartc and/or frog |
| 336 // test('const fields are immutable', () { | 340 // test('const fields are immutable', () { |
| 337 // var fragment = new DocumentFragment(); | 341 // var fragment = new DocumentFragment(); |
| 338 // assertConstError(() => fragment.attributes['title'] = 'foo'); | 342 // assertConstError(() => fragment.attributes['title'] = 'foo'); |
| 339 // assertConstError(() => fragment.dataAttributes['title'] = 'foo'); | 343 // assertConstError(() => fragment.dataAttributes['title'] = 'foo'); |
| 340 // fragment.rect.then((ElementRect rect) { | 344 // fragment.rect.then((ElementRect rect) { |
| 341 // assertConstError(() => rect.clientRects.add(null)); | 345 // assertConstError(() => rect.clientRects.add(null)); |
| 342 // callbackDone(); | 346 // callbackDone(); |
| 343 // }); | 347 // }); |
| 344 // // Issue 174: #classes is currently not const | 348 // // Issue 174: #classes is currently not const |
| 345 // // assertConstError(() => fragment.classes.add('foo')); | 349 // // assertConstError(() => fragment.classes.add('foo')); |
| 346 // }); | 350 // }); |
| 347 | 351 |
| 348 test('query searches the fragment', () { | 352 test('query searches the fragment', () { |
| 349 var fragment = new DocumentFragment.html( | 353 var fragment = new DocumentFragment.html( |
| 350 "<div class='foo'><a>foo</a><b>bar</b></div>"); | 354 "<div class='foo'><a>foo</a><b>bar</b></div>"); |
| 351 Expect.equals("A", fragment.query(".foo a").tagName); | 355 expect(fragment.query(".foo a").tagName, "A"); |
| 352 Expect.listEquals(["A", "B"], _nodeStrings(fragment.queryAll(".foo *"))); | 356 expect(_nodeStrings(fragment.queryAll(".foo *")), equals(["A", "B"])); |
| 353 }); | 357 }); |
| 354 } | 358 } |
| OLD | NEW |