diff options
author | hirono@chromium.org <hirono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-22 16:57:06 +0000 |
---|---|---|
committer | hirono@chromium.org <hirono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-22 16:57:06 +0000 |
commit | f8deef3b9b4288d5ea61e53a5a8b3bfb9b70b82f (patch) | |
tree | b79fa97558b4e3b5ffede4b901ae2731d0bb8f35 | |
parent | 44ae3805739ead40b851d4f25ec378ca03a35102 (diff) | |
download | chromium_src-f8deef3b9b4288d5ea61e53a5a8b3bfb9b70b82f.zip chromium_src-f8deef3b9b4288d5ea61e53a5a8b3bfb9b70b82f.tar.gz chromium_src-f8deef3b9b4288d5ea61e53a5a8b3bfb9b70b82f.tar.bz2 |
webui: Clear a pinned item when the data model is permuted.
At #1200 of list.js, the comment says a pinned item is preserved til the data
model is changed. But the pinned item is not cleared in the permuted event
handler, and it causes inconsistency between the data model and the cached
items.
BUG=352516
TEST=manually
Review URL: https://codereview.chromium.org/244703002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265284 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/test/data/webui/list_test.html | 33 | ||||
-rw-r--r-- | chrome/test/data/webui/webui_resource_browsertest.cc | 12 | ||||
-rw-r--r-- | ui/webui/resources/js/cr/ui/list.js | 1 |
3 files changed, 46 insertions, 0 deletions
diff --git a/chrome/test/data/webui/list_test.html b/chrome/test/data/webui/list_test.html new file mode 100644 index 0000000..a9239e9 --- /dev/null +++ b/chrome/test/data/webui/list_test.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<html> +<body> + +<script> + +function testClearPinnedItem() { + var list = document.createElement('ul'); + list.style.position = 'absolute'; + list.style.width = '800px'; + list.style.height = '800px'; + cr.ui.List.decorate(list); + document.body.appendChild(list); + + var model = new cr.ui.ArrayDataModel(['Item A', 'Item B']); + list.dataModel = model; + list.selectionModel.setIndexSelected(0, true); + list.selectionModel.leadIndex = 0; + list.ensureLeadItemExists(); + + list.style.height = '0px'; + model.splice(0, 1); + + list.style.height = '800px'; + list.redraw(); + assertEquals('Item B', + list.querySelectorAll('li')[0].textContent); +} + +</script> + +</body> +</html> diff --git a/chrome/test/data/webui/webui_resource_browsertest.cc b/chrome/test/data/webui/webui_resource_browsertest.cc index ee49f10..acdbe2d 100644 --- a/chrome/test/data/webui/webui_resource_browsertest.cc +++ b/chrome/test/data/webui/webui_resource_browsertest.cc @@ -59,6 +59,18 @@ IN_PROC_BROWSER_TEST_F(WebUIResourceBrowserTest, EventTargetTest) { RunTest(base::FilePath(FILE_PATH_LITERAL("event_target_test.html"))); } +IN_PROC_BROWSER_TEST_F(WebUIResourceBrowserTest, ListTest) { + AddLibrary(IDR_WEBUI_JS_CR); + AddLibrary(IDR_WEBUI_JS_CR_EVENT_TARGET); + AddLibrary(IDR_WEBUI_JS_CR_UI); + AddLibrary(IDR_WEBUI_JS_CR_UI_ARRAY_DATA_MODEL); + AddLibrary(IDR_WEBUI_JS_CR_UI_LIST_ITEM); + AddLibrary(IDR_WEBUI_JS_CR_UI_LIST_SELECTION_CONTROLLER); + AddLibrary(IDR_WEBUI_JS_CR_UI_LIST_SELECTION_MODEL); + AddLibrary(IDR_WEBUI_JS_CR_UI_LIST); + RunTest(base::FilePath(FILE_PATH_LITERAL("list_test.html"))); +} + IN_PROC_BROWSER_TEST_F(WebUIResourceBrowserTest, GridTest) { AddLibrary(IDR_WEBUI_JS_CR); AddLibrary(IDR_WEBUI_JS_CR_EVENT_TARGET); diff --git a/ui/webui/resources/js/cr/ui/list.js b/ui/webui/resources/js/cr/ui/list.js index 1dc38b6..3f1d1a8 100644 --- a/ui/webui/resources/js/cr/ui/list.js +++ b/ui/webui/resources/js/cr/ui/list.js @@ -631,6 +631,7 @@ cr.define('cr.ui', function() { } } this.cachedItems_ = newCachedItems; + this.pinnedItem_ = null; var newCachedItemHeights = {}; for (var index in this.cachedItemHeights_) { |