| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 Copyright (c) 2013, 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 17 matching lines...) Expand all Loading... |
| 28 main() { | 28 main() { |
| 29 Timer.run(() { | 29 Timer.run(() { |
| 30 useShadowDom = false; | 30 useShadowDom = false; |
| 31 app.todos.add(new Todo('one (unchecked)')); | 31 app.todos.add(new Todo('one (unchecked)')); |
| 32 app.todos.add(new Todo('two (unchecked)')); | 32 app.todos.add(new Todo('two (unchecked)')); |
| 33 app.todos.add(new Todo('three (checked)')..done = true); | 33 app.todos.add(new Todo('three (checked)')..done = true); |
| 34 app.todos.add(new Todo('four (checked)')); | 34 app.todos.add(new Todo('four (checked)')); |
| 35 deliverChangesSync(); | 35 deliverChangesSync(); |
| 36 | 36 |
| 37 // To ensure we click in the correct place, we calculate x, y offset where | 37 // To ensure we click in the correct place, we calculate x, y offset where |
| 38 // we want to click based on the coordinates given by DumpRenderTree, and | 38 // we want to click based on the coordinates given by content shell, and |
| 39 // then adapt those offset in the current window. This makes is possible to | 39 // then adapt those offset in the current window. This makes is possible to |
| 40 // debug the application in Dartium reliably. | 40 // debug the application in Dartium reliably. |
| 41 | 41 |
| 42 var bounding = document.body.getBoundingClientRect(); | 42 var bounding = document.body.getBoundingClientRect(); |
| 43 // The x, y location of body in the DumpRenderTree output was: (117, 130) | 43 // The x, y location of body in the content shell output was: (117, 130) |
| 44 // and location of the node we want to click was: (119, 398) | 44 // and location of the node we want to click was: (119, 398) |
| 45 int x = bounding.left.toInt() + (119 - 117); | 45 int x = bounding.left.toInt() + (119 - 117); |
| 46 int y = bounding.top.toInt() + (398 - 130); | 46 int y = bounding.top.toInt() + (398 - 130); |
| 47 var node = document.elementFromPoint(x, y); | 47 var node = document.elementFromPoint(x, y); |
| 48 expect(node is InputElement, isTrue, | 48 expect(node is InputElement, isTrue, |
| 49 reason: '$x, $y points to a checkbox'); | 49 reason: '$x, $y points to a checkbox'); |
| 50 expect(node.checked, isFalse, reason: 'element is unchecked'); | 50 expect(node.checked, isFalse, reason: 'element is unchecked'); |
| 51 Element parent = node.parent; | 51 Element parent = node.parent; |
| 52 expect(parent.query('label').text, equals('four (checked)')); | 52 expect(parent.query('label').text, equals('four (checked)')); |
| 53 node.dispatchEvent(new MouseEvent('click', detail: 1)); | 53 node.dispatchEvent(new MouseEvent('click', detail: 1)); |
| 54 expect(node.checked, isTrue, reason: 'element is checked'); | 54 expect(node.checked, isTrue, reason: 'element is checked'); |
| 55 | 55 |
| 56 // Ideally the test above would work also with shadow DOM (pending that | 56 // Ideally the test above would work also with shadow DOM (pending that |
| 57 // 'elementFromPoint' is fixed to return also nodes under the shadow DOM). | 57 // 'elementFromPoint' is fixed to return also nodes under the shadow DOM). |
| 58 // The next extra check is only valid when polyfilling the shadow DOM: | 58 // The next extra check is only valid when polyfilling the shadow DOM: |
| 59 expect(node, same(document.queryAll('input[type=checkbox]')[4])); | 59 expect(node, same(document.queryAll('input[type=checkbox]')[4])); |
| 60 | 60 |
| 61 window.postMessage('done', '*'); | 61 window.postMessage('done', '*'); |
| 62 }); | 62 }); |
| 63 } | 63 } |
| 64 </script> | 64 </script> |
| 65 </body> | 65 </body> |
| 66 </html> | 66 </html> |
| OLD | NEW |