OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
4 for details. All rights reserved. Use of this source code is governed by a | 4 for details. All rights reserved. Use of this source code is governed by a |
5 BSD-style license that can be found in the LICENSE file. | 5 BSD-style license that can be found in the LICENSE file. |
6 --> | 6 --> |
7 <html lang="en"> | 7 <html lang="en"> |
8 <head> | 8 <head> |
9 <!-- | 9 <!-- |
10 This test runs the TodoMVC app, adds a few todos, marks some as done | 10 This test runs the TodoMVC app, adds a few todos, marks some as done |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 main() { | 77 main() { |
78 todomvc_main.main(); | 78 todomvc_main.main(); |
79 | 79 |
80 window.setTimeout(() { | 80 window.setTimeout(() { |
81 useShadowDom = false; | 81 useShadowDom = false; |
82 app.todos.add(new Todo('one (unchecked)')); | 82 app.todos.add(new Todo('one (unchecked)')); |
83 app.todos.add(new Todo('two (unchecked)')); | 83 app.todos.add(new Todo('two (unchecked)')); |
84 app.todos.add(new Todo('three (checked)')..done = true); | 84 app.todos.add(new Todo('three (checked)')..done = true); |
85 app.todos.add(new Todo('four (checked)')); | 85 app.todos.add(new Todo('four (checked)')); |
86 dispatch(); | 86 deliverChangesSync(); |
87 | 87 |
88 // To ensure we click in the correct place, we calculate x, y offset where | 88 // To ensure we click in the correct place, we calculate x, y offset where |
89 // we want to click based on the coordinates given by DumpRenderTree, and | 89 // we want to click based on the coordinates given by DumpRenderTree, and |
90 // then adapt those offset in the current window. This makes is possible to | 90 // then adapt those offset in the current window. This makes is possible to |
91 // debug the application in Dartium reliably. | 91 // debug the application in Dartium reliably. |
92 | 92 |
93 var bounding = document.body.getBoundingClientRect(); | 93 var bounding = document.body.getBoundingClientRect(); |
94 // The x, y location of body in the DumpRenderTree output was: (117, 130) | 94 // The x, y location of body in the DumpRenderTree output was: (117, 130) |
95 // and location of the node we want to click was: (119, 398) | 95 // and location of the node we want to click was: (119, 398) |
96 int x = bounding.left.toInt() + (119 - 117); | 96 int x = bounding.left.toInt() + (119 - 117); |
97 int y = bounding.top.toInt() + (398 - 130); | 97 int y = bounding.top.toInt() + (398 - 130); |
98 var node = document.elementFromPoint(x, y); | 98 var node = document.elementFromPoint(x, y); |
99 expect(node is InputElement, isTrue, | 99 expect(node is InputElement, isTrue, |
100 reason: '$x, $y points to a checkbox'); | 100 reason: '$x, $y points to a checkbox'); |
101 expect(node.checked, isFalse, reason: 'element is unchecked'); | 101 expect(node.checked, isFalse, reason: 'element is unchecked'); |
102 Element parent = node.parent; | 102 Element parent = node.parent; |
103 expect(parent.query('label').text, equals('four (checked)')); | 103 expect(parent.query('label').text, equals('four (checked)')); |
104 node.dispatchEvent(new MouseEvent('click', detail: 1)); | 104 node.dispatchEvent(new MouseEvent('click', detail: 1)); |
105 expect(node.checked, isTrue, reason: 'element is checked'); | 105 expect(node.checked, isTrue, reason: 'element is checked'); |
106 | 106 |
107 // Ideally the test above would work also with shadow DOM (pending that | 107 // Ideally the test above would work also with shadow DOM (pending that |
108 // 'elementFromPoint' is fixed to return also nodes under the shadow DOM). | 108 // 'elementFromPoint' is fixed to return also nodes under the shadow DOM). |
109 // The next extra check is only valid when polyfilling the shadow DOM: | 109 // The next extra check is only valid when polyfilling the shadow DOM: |
110 expect(node, same(document.queryAll('input[type=checkbox]')[4])); | 110 expect(node, same(document.queryAll('input[type=checkbox]')[4])); |
111 | 111 |
112 window.setTimeout(() => window.postMessage('done', '*'), 0); | 112 window.setImmediate(() => window.postMessage('done', '*')); |
113 }, 0); | 113 }, 0); |
114 } | 114 } |
115 </script> | 115 </script> |
116 </body> | 116 </body> |
117 </html> | 117 </html> |
OLD | NEW |