browser/devtools/debugger/test/browser_dbg_addon-modules-unpacked.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 // Make sure the add-on actor can see loaded JS Modules from an add-on
michael@0 5
michael@0 6 const ADDON_URL = EXAMPLE_URL + "addon5.xpi";
michael@0 7
michael@0 8 function test() {
michael@0 9 Task.spawn(function () {
michael@0 10 let addon = yield addAddon(ADDON_URL);
michael@0 11 let tab1 = yield addTab("chrome://browser_dbg_addon5/content/test.xul");
michael@0 12
michael@0 13 let addonDebugger = yield initAddonDebugger(ADDON_URL);
michael@0 14
michael@0 15 is(addonDebugger.title, "Debugger - Test unpacked add-on with JS Modules", "Saw the right toolbox title.");
michael@0 16
michael@0 17 // Check the inital list of sources is correct
michael@0 18 let groups = yield addonDebugger.getSourceGroups();
michael@0 19 is(groups[0].name, "browser_dbg_addon5@tests.mozilla.org", "Add-on code should be the first group");
michael@0 20 is(groups[1].name, "chrome://global", "XUL code should be the second group");
michael@0 21 is(groups.length, 2, "Should be only two groups.");
michael@0 22
michael@0 23 let sources = groups[0].sources;
michael@0 24 is(sources.length, 3, "Should be three sources");
michael@0 25 ok(sources[0].url.endsWith("/browser_dbg_addon5@tests.mozilla.org/bootstrap.js"), "correct url for bootstrap code")
michael@0 26 is(sources[0].label, "bootstrap.js", "correct label for bootstrap code")
michael@0 27 is(sources[1].url, "resource://browser_dbg_addon5/test.jsm", "correct url for addon code")
michael@0 28 is(sources[1].label, "test.jsm", "correct label for addon code")
michael@0 29 is(sources[2].url, "chrome://browser_dbg_addon5/content/testxul.js", "correct url for addon tab code")
michael@0 30 is(sources[2].label, "testxul.js", "correct label for addon tab code")
michael@0 31
michael@0 32 // Load a new module and tab and check they appear in the list of sources
michael@0 33 Cu.import("resource://browser_dbg_addon5/test2.jsm", {});
michael@0 34 let tab2 = yield addTab("chrome://browser_dbg_addon5/content/test2.xul");
michael@0 35
michael@0 36 groups = yield addonDebugger.getSourceGroups();
michael@0 37 is(groups[0].name, "browser_dbg_addon5@tests.mozilla.org", "Add-on code should be the first group");
michael@0 38 is(groups[1].name, "chrome://global", "XUL code should be the second group");
michael@0 39 is(groups.length, 2, "Should be only two groups.");
michael@0 40
michael@0 41 sources = groups[0].sources;
michael@0 42 is(sources.length, 5, "Should be five sources");
michael@0 43 ok(sources[0].url.endsWith("/browser_dbg_addon5@tests.mozilla.org/bootstrap.js"), "correct url for bootstrap code")
michael@0 44 is(sources[0].label, "bootstrap.js", "correct label for bootstrap code")
michael@0 45 is(sources[1].url, "resource://browser_dbg_addon5/test.jsm", "correct url for addon code")
michael@0 46 is(sources[1].label, "test.jsm", "correct label for addon code")
michael@0 47 is(sources[2].url, "chrome://browser_dbg_addon5/content/testxul.js", "correct url for addon tab code")
michael@0 48 is(sources[2].label, "testxul.js", "correct label for addon tab code")
michael@0 49 is(sources[3].url, "resource://browser_dbg_addon5/test2.jsm", "correct url for addon code")
michael@0 50 is(sources[3].label, "test2.jsm", "correct label for addon code")
michael@0 51 is(sources[4].url, "chrome://browser_dbg_addon5/content/testxul2.js", "correct url for addon tab code")
michael@0 52 is(sources[4].label, "testxul2.js", "correct label for addon tab code")
michael@0 53
michael@0 54 Cu.unload("resource://browser_dbg_addon5/test2.jsm");
michael@0 55 yield addonDebugger.destroy();
michael@0 56 yield removeTab(tab1);
michael@0 57 yield removeTab(tab2);
michael@0 58 yield removeAddon(addon);
michael@0 59 finish();
michael@0 60 });
michael@0 61 }

mercurial