1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/newtab/browser_newtab_drag_drop.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,74 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/* 1.8 + * These tests make sure that dragging and dropping sites works as expected. 1.9 + * Sites contained in the grid need to shift around to indicate the result 1.10 + * of the drag-and-drop operation. If the grid is full and we're dragging 1.11 + * a new site into it another one gets pushed out. 1.12 + */ 1.13 +function runTests() { 1.14 + requestLongerTimeout(2); 1.15 + 1.16 + // test a simple drag-and-drop scenario 1.17 + yield setLinks("0,1,2,3,4,5,6,7,8"); 1.18 + setPinnedLinks(""); 1.19 + 1.20 + yield addNewTabPageTab(); 1.21 + checkGrid("0,1,2,3,4,5,6,7,8"); 1.22 + 1.23 + yield simulateDrop(0, 1); 1.24 + checkGrid("1,0p,2,3,4,5,6,7,8"); 1.25 + 1.26 + // drag a cell to its current cell and make sure it's not pinned afterwards 1.27 + yield setLinks("0,1,2,3,4,5,6,7,8"); 1.28 + setPinnedLinks(""); 1.29 + 1.30 + yield addNewTabPageTab(); 1.31 + checkGrid("0,1,2,3,4,5,6,7,8"); 1.32 + 1.33 + yield simulateDrop(0, 0); 1.34 + checkGrid("0,1,2,3,4,5,6,7,8"); 1.35 + 1.36 + // ensure that pinned pages aren't moved if that's not necessary 1.37 + yield setLinks("0,1,2,3,4,5,6,7,8"); 1.38 + setPinnedLinks(",1,2"); 1.39 + 1.40 + yield addNewTabPageTab(); 1.41 + checkGrid("0,1p,2p,3,4,5,6,7,8"); 1.42 + 1.43 + yield simulateDrop(0, 3); 1.44 + checkGrid("3,1p,2p,0p,4,5,6,7,8"); 1.45 + 1.46 + // pinned sites should always be moved around as blocks. if a pinned site is 1.47 + // moved around, neighboring pinned are affected as well 1.48 + yield setLinks("0,1,2,3,4,5,6,7,8"); 1.49 + setPinnedLinks("0,1"); 1.50 + 1.51 + yield addNewTabPageTab(); 1.52 + checkGrid("0p,1p,2,3,4,5,6,7,8"); 1.53 + 1.54 + yield simulateDrop(2, 0); 1.55 + checkGrid("2p,0p,1p,3,4,5,6,7,8"); 1.56 + 1.57 + // pinned sites should not be pushed out of the grid (unless there are only 1.58 + // pinned ones left on the grid) 1.59 + yield setLinks("0,1,2,3,4,5,6,7,8"); 1.60 + setPinnedLinks(",,,,,,,7,8"); 1.61 + 1.62 + yield addNewTabPageTab(); 1.63 + checkGrid("0,1,2,3,4,5,6,7p,8p"); 1.64 + 1.65 + yield simulateDrop(2, 8); 1.66 + checkGrid("0,1,3,4,5,6,7p,8p,2p"); 1.67 + 1.68 + // make sure that pinned sites are re-positioned correctly 1.69 + yield setLinks("0,1,2,3,4,5,6,7,8"); 1.70 + setPinnedLinks("0,1,2,,,5"); 1.71 + 1.72 + yield addNewTabPageTab(); 1.73 + checkGrid("0p,1p,2p,3,4,5p,6,7,8"); 1.74 + 1.75 + yield simulateDrop(0, 4); 1.76 + checkGrid("3,1p,2p,4,0p,5p,6,7,8"); 1.77 +}