Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for plugin child widgets not being invalidated by scrolling</title> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 7 | </head> |
michael@0 | 8 | <body onload="initialize()"> |
michael@0 | 9 | <script type="application/javascript"> |
michael@0 | 10 | var pluginHost = SpecialPowers.Cc["@mozilla.org/plugin/host;1"] |
michael@0 | 11 | .getService(SpecialPowers.Ci.nsIPluginHost); |
michael@0 | 12 | var pluginTags = pluginHost.getPluginTags(); |
michael@0 | 13 | for (var tag of pluginTags) { |
michael@0 | 14 | if (tag.name == "Test Plug-in") { |
michael@0 | 15 | tag.enabledState = SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED;; |
michael@0 | 16 | } |
michael@0 | 17 | } |
michael@0 | 18 | </script> |
michael@0 | 19 | |
michael@0 | 20 | <p id="display"> |
michael@0 | 21 | <iframe id="i" src="plugin_scroll_invalidation.html" |
michael@0 | 22 | width="50" height="50" scrolling="no"></iframe> |
michael@0 | 23 | </p> |
michael@0 | 24 | <div id="content" style="display: none"> |
michael@0 | 25 | |
michael@0 | 26 | </div> |
michael@0 | 27 | <pre id="test"> |
michael@0 | 28 | </pre> |
michael@0 | 29 | |
michael@0 | 30 | <script type="application/javascript"> |
michael@0 | 31 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 32 | |
michael@0 | 33 | var scrolling; |
michael@0 | 34 | var scrolling_plugins = []; |
michael@0 | 35 | var paint_waiter; |
michael@0 | 36 | var last_paint_counts; |
michael@0 | 37 | |
michael@0 | 38 | function initialize() { |
michael@0 | 39 | scrolling = document.getElementById("i").contentWindow; |
michael@0 | 40 | scrolling_plugins = scrolling.document.querySelectorAll("embed.scrolling"); |
michael@0 | 41 | paint_waiter = scrolling.document.getElementById("paint-waiter"); |
michael@0 | 42 | |
michael@0 | 43 | scrolling.scrollTo(50, 45); |
michael@0 | 44 | |
michael@0 | 45 | is(paint_waiter.getPaintCount(), 0, "zero-sized plugin not painted"); |
michael@0 | 46 | |
michael@0 | 47 | waitForPaint(scrollAround); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function scrollAround() { |
michael@0 | 51 | var paints = getPaintCounts(); |
michael@0 | 52 | |
michael@0 | 53 | for (var i = 0; i < paints.length; ++i) { |
michael@0 | 54 | isnot(paints[i], 0, "embed " + scrolling_plugins[i].id + " is painted"); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | last_paint_counts = paints; |
michael@0 | 58 | |
michael@0 | 59 | scrolling.scrollBy(-5, 5); |
michael@0 | 60 | scrolling.scrollBy(5, 5); |
michael@0 | 61 | scrolling.scrollBy(5, -5); |
michael@0 | 62 | scrolling.scrollBy(-5, -5); |
michael@0 | 63 | |
michael@0 | 64 | scrolling.scrollTo(45, 45); |
michael@0 | 65 | scrolling.scrollBy(10, 0); |
michael@0 | 66 | scrolling.scrollBy(0, 10); |
michael@0 | 67 | scrolling.scrollBy(-10, 0); |
michael@0 | 68 | scrolling.scrollBy(0, -10); |
michael@0 | 69 | |
michael@0 | 70 | waitForPaint(done); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | function done() { |
michael@0 | 74 | var paints = getPaintCounts(); |
michael@0 | 75 | for (var i = 0; i < paints.length; ++i) { |
michael@0 | 76 | is(paints[i], last_paint_counts[i], "embed " + scrolling_plugins[i].id + " is not painted on scroll"); |
michael@0 | 77 | } |
michael@0 | 78 | SimpleTest.finish(); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | // Waits for the paint_waiter plugin to be repainted and then |
michael@0 | 82 | // calls 'func' to continue. |
michael@0 | 83 | function waitForPaint(func) { |
michael@0 | 84 | paint_waiter.last_paint_count = paint_waiter.getPaintCount(); |
michael@0 | 85 | |
michael@0 | 86 | paint_waiter.style.left = scrolling.scrollX + "px"; |
michael@0 | 87 | paint_waiter.style.top = scrolling.scrollY + "px"; |
michael@0 | 88 | |
michael@0 | 89 | // Fiddle with the style in a way that should force some repainting |
michael@0 | 90 | paint_waiter.style.width = |
michael@0 | 91 | (paint_waiter.getBoundingClientRect().width + 1) + "px"; |
michael@0 | 92 | paint_waiter.style.height = "1px"; |
michael@0 | 93 | |
michael@0 | 94 | function waitForPaintHelper() { |
michael@0 | 95 | if (paint_waiter.getPaintCount() != paint_waiter.last_paint_count) { |
michael@0 | 96 | setTimeout(func, 0); |
michael@0 | 97 | return; |
michael@0 | 98 | } |
michael@0 | 99 | setTimeout(waitForPaintHelper, 0); |
michael@0 | 100 | } |
michael@0 | 101 | waitForPaintHelper(); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | function getPaintCounts() { |
michael@0 | 105 | var result = []; |
michael@0 | 106 | for (var i = 0; i < scrolling_plugins.length; ++i) { |
michael@0 | 107 | result[i] = scrolling_plugins[i].getPaintCount(); |
michael@0 | 108 | } |
michael@0 | 109 | return result; |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | </script> |
michael@0 | 113 | </body> |
michael@0 | 114 | </html> |