| // Copyright 2017 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| (async function() { |
| TestRunner.addResult(`Verifies that entering poor property value restores original text.\n`); |
| await TestRunner.loadModule('elements_test_runner'); |
| await TestRunner.showPanel('elements'); |
| await TestRunner.loadHTML(` |
| <style> |
| #inspected { |
| color: blue; |
| } |
| </style> |
| <div id="inspected">Text</div> |
| `); |
| |
| var treeElement; |
| ElementsTestRunner.selectNodeAndWaitForStyles('inspected', editProperty); |
| |
| async function editProperty() { |
| treeElement = ElementsTestRunner.getMatchedStylePropertyTreeItem('color'); |
| await ElementsTestRunner.dumpSelectedElementStyles(true, false, true); |
| treeElement.startEditing(); |
| treeElement.nameElement.textContent = 'color'; |
| treeElement.nameElement.dispatchEvent(TestRunner.createKeyEvent('Enter')); |
| treeElement.valueElement.textContent = 'red'; |
| treeElement.kickFreeFlowStyleEditForTest().then(commitInvalidProperty); |
| } |
| |
| function commitInvalidProperty() { |
| treeElement.valueElement.textContent = 'red/*'; |
| ElementsTestRunner.waitForStyleCommitted(dumpAndExit); |
| treeElement.valueElement.dispatchEvent(TestRunner.createKeyEvent('Enter')); |
| } |
| |
| async function dumpAndExit() { |
| await ElementsTestRunner.dumpSelectedElementStyles(true, false, true); |
| TestRunner.completeTest(); |
| } |
| })(); |