Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 /*
5 * These tests make sure that dragging and dropping sites works as expected.
6 * Sites contained in the grid need to shift around to indicate the result
7 * of the drag-and-drop operation. If the grid is full and we're dragging
8 * a new site into it another one gets pushed out.
9 */
10 function runTests() {
11 requestLongerTimeout(2);
13 // test a simple drag-and-drop scenario
14 yield setLinks("0,1,2,3,4,5,6,7,8");
15 setPinnedLinks("");
17 yield addNewTabPageTab();
18 checkGrid("0,1,2,3,4,5,6,7,8");
20 yield simulateDrop(0, 1);
21 checkGrid("1,0p,2,3,4,5,6,7,8");
23 // drag a cell to its current cell and make sure it's not pinned afterwards
24 yield setLinks("0,1,2,3,4,5,6,7,8");
25 setPinnedLinks("");
27 yield addNewTabPageTab();
28 checkGrid("0,1,2,3,4,5,6,7,8");
30 yield simulateDrop(0, 0);
31 checkGrid("0,1,2,3,4,5,6,7,8");
33 // ensure that pinned pages aren't moved if that's not necessary
34 yield setLinks("0,1,2,3,4,5,6,7,8");
35 setPinnedLinks(",1,2");
37 yield addNewTabPageTab();
38 checkGrid("0,1p,2p,3,4,5,6,7,8");
40 yield simulateDrop(0, 3);
41 checkGrid("3,1p,2p,0p,4,5,6,7,8");
43 // pinned sites should always be moved around as blocks. if a pinned site is
44 // moved around, neighboring pinned are affected as well
45 yield setLinks("0,1,2,3,4,5,6,7,8");
46 setPinnedLinks("0,1");
48 yield addNewTabPageTab();
49 checkGrid("0p,1p,2,3,4,5,6,7,8");
51 yield simulateDrop(2, 0);
52 checkGrid("2p,0p,1p,3,4,5,6,7,8");
54 // pinned sites should not be pushed out of the grid (unless there are only
55 // pinned ones left on the grid)
56 yield setLinks("0,1,2,3,4,5,6,7,8");
57 setPinnedLinks(",,,,,,,7,8");
59 yield addNewTabPageTab();
60 checkGrid("0,1,2,3,4,5,6,7p,8p");
62 yield simulateDrop(2, 8);
63 checkGrid("0,1,3,4,5,6,7p,8p,2p");
65 // make sure that pinned sites are re-positioned correctly
66 yield setLinks("0,1,2,3,4,5,6,7,8");
67 setPinnedLinks("0,1,2,,,5");
69 yield addNewTabPageTab();
70 checkGrid("0p,1p,2p,3,4,5p,6,7,8");
72 yield simulateDrop(0, 4);
73 checkGrid("3,1p,2p,4,0p,5p,6,7,8");
74 }