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.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" |
michael@0 | 4 | type="text/css"?> |
michael@0 | 5 | <window title="Taskbar Previews Test" |
michael@0 | 6 | xmlns:html="http://www.w3.org/1999/xhtml" |
michael@0 | 7 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 8 | onload="loaded();"> |
michael@0 | 9 | |
michael@0 | 10 | <title>Previews - yeah!</title> |
michael@0 | 11 | <script type="application/javascript" |
michael@0 | 12 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> |
michael@0 | 13 | <script class="testbody" type="application/javascript"> |
michael@0 | 14 | <![CDATA[ |
michael@0 | 15 | let Cc = Components.classes; |
michael@0 | 16 | let Ci = Components.interfaces; |
michael@0 | 17 | let Cu = Components.utils; |
michael@0 | 18 | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 19 | |
michael@0 | 20 | let taskbar = Cc["@mozilla.org/windows-taskbar;1"].getService(Ci.nsIWinTaskbar); |
michael@0 | 21 | |
michael@0 | 22 | function IsWin7OrHigher() { |
michael@0 | 23 | try { |
michael@0 | 24 | var sysInfo = Cc["@mozilla.org/system-info;1"]. |
michael@0 | 25 | getService(Ci.nsIPropertyBag2); |
michael@0 | 26 | var ver = parseFloat(sysInfo.getProperty("version")); |
michael@0 | 27 | if (ver >= 6.1) |
michael@0 | 28 | return true; |
michael@0 | 29 | } catch (ex) { } |
michael@0 | 30 | return false; |
michael@0 | 31 | } |
michael@0 | 32 | isnot(taskbar, null, "Taskbar service is defined"); |
michael@0 | 33 | is(taskbar.available, IsWin7OrHigher(), "Expected availability of taskbar"); |
michael@0 | 34 | |
michael@0 | 35 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 36 | |
michael@0 | 37 | function stdPreviewSuite(p) { |
michael@0 | 38 | p.visible = !p.visible; |
michael@0 | 39 | p.visible = !p.visible; |
michael@0 | 40 | p.visible = true; |
michael@0 | 41 | p.invalidate(); |
michael@0 | 42 | p.visible = false; |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function loaded() |
michael@0 | 46 | { |
michael@0 | 47 | if (!taskbar.available) |
michael@0 | 48 | SimpleTest.finish(); |
michael@0 | 49 | let controller = { |
michael@0 | 50 | width: 400, |
michael@0 | 51 | height: 400, |
michael@0 | 52 | thumbnailAspectRatio: 1.0, |
michael@0 | 53 | drawThumbnail: function () { return false; }, |
michael@0 | 54 | drawPreview: function () { return false; }, |
michael@0 | 55 | get wrappedJSObject() { return this; } |
michael@0 | 56 | } |
michael@0 | 57 | // HACK from mconnor: |
michael@0 | 58 | var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); |
michael@0 | 59 | let win = wm.getMostRecentWindow("navigator:browser"); |
michael@0 | 60 | let docShell = win.gBrowser.docShell; |
michael@0 | 61 | |
michael@0 | 62 | let winPreview = taskbar.getTaskbarWindowPreview(docShell); |
michael@0 | 63 | isnot(winPreview, null, "Window preview is not null"); |
michael@0 | 64 | winPreview.controller = controller; |
michael@0 | 65 | let button = winPreview.getButton(0); |
michael@0 | 66 | isnot(button, null, "Could get button at valid index"); |
michael@0 | 67 | try { |
michael@0 | 68 | winPreview.getButton(-1); |
michael@0 | 69 | ok(false, "Got button at negative index"); |
michael@0 | 70 | } catch (ex) {} |
michael@0 | 71 | try { |
michael@0 | 72 | winPreview.getButton(Ci.nsITaskbarWindowPreview.NUM_TOOLBAR_BUTTONS); |
michael@0 | 73 | ok(false, "Got button at index that is too large"); |
michael@0 | 74 | } catch (ex) {} |
michael@0 | 75 | button.image = null; |
michael@0 | 76 | stdPreviewSuite(winPreview); |
michael@0 | 77 | // Let's not perma-hide this window from the taskbar |
michael@0 | 78 | winPreview.visible = true; |
michael@0 | 79 | |
michael@0 | 80 | let tabP = taskbar.createTaskbarTabPreview(docShell, controller); |
michael@0 | 81 | isnot(tabP, null, "Tab preview is not null"); |
michael@0 | 82 | is(tabP.controller.wrappedJSObject, controller, "Controllers match"); |
michael@0 | 83 | is(tabP.icon, null, "Default icon is null (windows default)"); |
michael@0 | 84 | tabP.icon = null; |
michael@0 | 85 | tabP.move(null); |
michael@0 | 86 | try { |
michael@0 | 87 | tabP.move(tabP); |
michael@0 | 88 | ok(false, "Moved a preview next to itself!"); |
michael@0 | 89 | } catch (ex) {} |
michael@0 | 90 | stdPreviewSuite(tabP); |
michael@0 | 91 | |
michael@0 | 92 | let tabP2 = taskbar.createTaskbarTabPreview(docShell, controller); |
michael@0 | 93 | tabP.visible = true; |
michael@0 | 94 | tabP2.visible = true; |
michael@0 | 95 | |
michael@0 | 96 | isnot(tabP2, null, "2nd Tab preview is not null"); |
michael@0 | 97 | isnot(tabP,tabP2, "Tab previews are different"); |
michael@0 | 98 | tabP.active = true; |
michael@0 | 99 | ok(tabP.active && !tabP2.active, "Only one tab is active (part 1)"); |
michael@0 | 100 | tabP2.active = true; |
michael@0 | 101 | ok(!tabP.active && tabP2.active, "Only one tab is active (part 2)"); |
michael@0 | 102 | tabP.active = true; |
michael@0 | 103 | ok(tabP.active && !tabP2.active, "Only one tab is active (part 3)"); |
michael@0 | 104 | tabP.active = false; |
michael@0 | 105 | ok(!tabP.active && !tabP2.active, "Neither tab is active"); |
michael@0 | 106 | is(winPreview.active, false, "Window preview is not active"); |
michael@0 | 107 | tabP.active = true; |
michael@0 | 108 | winPreview.active = true; |
michael@0 | 109 | ok(winPreview.active && !tabP.active, "Tab preview takes activation from window"); |
michael@0 | 110 | tabP.active = true; |
michael@0 | 111 | ok(tabP.active && !winPreview.active, "Tab preview takes activation from window"); |
michael@0 | 112 | |
michael@0 | 113 | tabP.visible = false; |
michael@0 | 114 | tabP2.visible = false; |
michael@0 | 115 | |
michael@0 | 116 | SimpleTest.finish(); |
michael@0 | 117 | } |
michael@0 | 118 | ]]> |
michael@0 | 119 | </script> |
michael@0 | 120 | |
michael@0 | 121 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 122 | <p id="display"></p> |
michael@0 | 123 | <div id="content" style="display: none"></div> |
michael@0 | 124 | <pre id="test"></pre> |
michael@0 | 125 | </body> |
michael@0 | 126 | |
michael@0 | 127 | </window> |