browser/base/content/test/newtab/browser_newtab_drag_drop.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /*
michael@0 5 * These tests make sure that dragging and dropping sites works as expected.
michael@0 6 * Sites contained in the grid need to shift around to indicate the result
michael@0 7 * of the drag-and-drop operation. If the grid is full and we're dragging
michael@0 8 * a new site into it another one gets pushed out.
michael@0 9 */
michael@0 10 function runTests() {
michael@0 11 requestLongerTimeout(2);
michael@0 12
michael@0 13 // test a simple drag-and-drop scenario
michael@0 14 yield setLinks("0,1,2,3,4,5,6,7,8");
michael@0 15 setPinnedLinks("");
michael@0 16
michael@0 17 yield addNewTabPageTab();
michael@0 18 checkGrid("0,1,2,3,4,5,6,7,8");
michael@0 19
michael@0 20 yield simulateDrop(0, 1);
michael@0 21 checkGrid("1,0p,2,3,4,5,6,7,8");
michael@0 22
michael@0 23 // drag a cell to its current cell and make sure it's not pinned afterwards
michael@0 24 yield setLinks("0,1,2,3,4,5,6,7,8");
michael@0 25 setPinnedLinks("");
michael@0 26
michael@0 27 yield addNewTabPageTab();
michael@0 28 checkGrid("0,1,2,3,4,5,6,7,8");
michael@0 29
michael@0 30 yield simulateDrop(0, 0);
michael@0 31 checkGrid("0,1,2,3,4,5,6,7,8");
michael@0 32
michael@0 33 // ensure that pinned pages aren't moved if that's not necessary
michael@0 34 yield setLinks("0,1,2,3,4,5,6,7,8");
michael@0 35 setPinnedLinks(",1,2");
michael@0 36
michael@0 37 yield addNewTabPageTab();
michael@0 38 checkGrid("0,1p,2p,3,4,5,6,7,8");
michael@0 39
michael@0 40 yield simulateDrop(0, 3);
michael@0 41 checkGrid("3,1p,2p,0p,4,5,6,7,8");
michael@0 42
michael@0 43 // pinned sites should always be moved around as blocks. if a pinned site is
michael@0 44 // moved around, neighboring pinned are affected as well
michael@0 45 yield setLinks("0,1,2,3,4,5,6,7,8");
michael@0 46 setPinnedLinks("0,1");
michael@0 47
michael@0 48 yield addNewTabPageTab();
michael@0 49 checkGrid("0p,1p,2,3,4,5,6,7,8");
michael@0 50
michael@0 51 yield simulateDrop(2, 0);
michael@0 52 checkGrid("2p,0p,1p,3,4,5,6,7,8");
michael@0 53
michael@0 54 // pinned sites should not be pushed out of the grid (unless there are only
michael@0 55 // pinned ones left on the grid)
michael@0 56 yield setLinks("0,1,2,3,4,5,6,7,8");
michael@0 57 setPinnedLinks(",,,,,,,7,8");
michael@0 58
michael@0 59 yield addNewTabPageTab();
michael@0 60 checkGrid("0,1,2,3,4,5,6,7p,8p");
michael@0 61
michael@0 62 yield simulateDrop(2, 8);
michael@0 63 checkGrid("0,1,3,4,5,6,7p,8p,2p");
michael@0 64
michael@0 65 // make sure that pinned sites are re-positioned correctly
michael@0 66 yield setLinks("0,1,2,3,4,5,6,7,8");
michael@0 67 setPinnedLinks("0,1,2,,,5");
michael@0 68
michael@0 69 yield addNewTabPageTab();
michael@0 70 checkGrid("0p,1p,2p,3,4,5p,6,7,8");
michael@0 71
michael@0 72 yield simulateDrop(0, 4);
michael@0 73 checkGrid("3,1p,2p,4,0p,5p,6,7,8");
michael@0 74 }

mercurial