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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/base/content/test/newtab/browser_newtab_bug765628.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,27 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +const BAD_DRAG_DATA = "javascript:alert('h4ck0rz');\nbad stuff";
     1.8 +const GOOD_DRAG_DATA = "http://example.com/#99\nsite 99";
     1.9 +
    1.10 +function runTests() {
    1.11 +  yield setLinks("0,1,2,3,4,5,6,7,8");
    1.12 +  setPinnedLinks("");
    1.13 +
    1.14 +  yield addNewTabPageTab();
    1.15 +  checkGrid("0,1,2,3,4,5,6,7,8");
    1.16 +
    1.17 +  sendDropEvent(0, BAD_DRAG_DATA);
    1.18 +  sendDropEvent(1, GOOD_DRAG_DATA);
    1.19 +
    1.20 +  yield whenPagesUpdated();
    1.21 +  checkGrid("0,99p,1,2,3,4,5,6,7");
    1.22 +}
    1.23 +
    1.24 +function sendDropEvent(aCellIndex, aDragData) {
    1.25 +  let ifaceReq = getContentWindow().QueryInterface(Ci.nsIInterfaceRequestor);
    1.26 +  let windowUtils = ifaceReq.getInterface(Ci.nsIDOMWindowUtils);
    1.27 +
    1.28 +  let event = createDragEvent("drop", aDragData);
    1.29 +  windowUtils.dispatchDOMEventViaPresShell(getCell(aCellIndex).node, event, true);
    1.30 +}

mercurial