toolkit/content/tests/browser/browser_browserDrop.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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 function test() {
michael@0 5 waitForExplicitFinish();
michael@0 6
michael@0 7 let newTab = gBrowser.selectedTab = gBrowser.addTab();
michael@0 8 registerCleanupFunction(function () {
michael@0 9 gBrowser.removeTab(newTab);
michael@0 10 });
michael@0 11
michael@0 12 let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
michael@0 13 getService(Ci.mozIJSSubScriptLoader);
michael@0 14 let ChromeUtils = {};
michael@0 15 scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js", ChromeUtils);
michael@0 16
michael@0 17 let browser = gBrowser.selectedBrowser;
michael@0 18
michael@0 19 var linkHandlerActivated = 0;
michael@0 20 // Don't worry about clobbering the droppedLinkHandler, since we're closing
michael@0 21 // this tab after the test anyways
michael@0 22 browser.droppedLinkHandler = function dlh(e, url, name) {
michael@0 23 linkHandlerActivated++;
michael@0 24 ok(!/(javascript|data)/i.test(url), "javascript link should not be dropped");
michael@0 25 }
michael@0 26
michael@0 27 var receivedDropCount = 0;
michael@0 28 function dropListener() {
michael@0 29 receivedDropCount++;
michael@0 30 if (receivedDropCount == triggeredDropCount) {
michael@0 31 // Wait for the browser's system-phase event handler to run.
michael@0 32 executeSoon(function () {
michael@0 33 is(linkHandlerActivated, validDropCount,
michael@0 34 "link handler was called correct number of times");
michael@0 35 finish();
michael@0 36 })
michael@0 37 }
michael@0 38 }
michael@0 39 browser.addEventListener("drop", dropListener, false);
michael@0 40 registerCleanupFunction(function () {
michael@0 41 browser.removeEventListener("drop", dropListener, false);
michael@0 42 });
michael@0 43
michael@0 44 var triggeredDropCount = 0;
michael@0 45 var validDropCount = 0;
michael@0 46 function drop(text, valid) {
michael@0 47 triggeredDropCount++;
michael@0 48 if (valid)
michael@0 49 validDropCount++;
michael@0 50 executeSoon(function () {
michael@0 51 ChromeUtils.synthesizeDrop(browser, browser, [[{type: "text/plain", data: text}]], "copy", window);
michael@0 52 });
michael@0 53 }
michael@0 54
michael@0 55 drop("mochi.test/first", true);
michael@0 56 drop("javascript:'bad'");
michael@0 57 drop("jAvascript:'also bad'");
michael@0 58 drop("mochi.test/second", true);
michael@0 59 drop("data:text/html,bad");
michael@0 60 drop("mochi.test/third", true);
michael@0 61 }

mercurial