1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_addon-modules-unpacked.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Make sure the add-on actor can see loaded JS Modules from an add-on 1.8 + 1.9 +const ADDON_URL = EXAMPLE_URL + "addon5.xpi"; 1.10 + 1.11 +function test() { 1.12 + Task.spawn(function () { 1.13 + let addon = yield addAddon(ADDON_URL); 1.14 + let tab1 = yield addTab("chrome://browser_dbg_addon5/content/test.xul"); 1.15 + 1.16 + let addonDebugger = yield initAddonDebugger(ADDON_URL); 1.17 + 1.18 + is(addonDebugger.title, "Debugger - Test unpacked add-on with JS Modules", "Saw the right toolbox title."); 1.19 + 1.20 + // Check the inital list of sources is correct 1.21 + let groups = yield addonDebugger.getSourceGroups(); 1.22 + is(groups[0].name, "browser_dbg_addon5@tests.mozilla.org", "Add-on code should be the first group"); 1.23 + is(groups[1].name, "chrome://global", "XUL code should be the second group"); 1.24 + is(groups.length, 2, "Should be only two groups."); 1.25 + 1.26 + let sources = groups[0].sources; 1.27 + is(sources.length, 3, "Should be three sources"); 1.28 + ok(sources[0].url.endsWith("/browser_dbg_addon5@tests.mozilla.org/bootstrap.js"), "correct url for bootstrap code") 1.29 + is(sources[0].label, "bootstrap.js", "correct label for bootstrap code") 1.30 + is(sources[1].url, "resource://browser_dbg_addon5/test.jsm", "correct url for addon code") 1.31 + is(sources[1].label, "test.jsm", "correct label for addon code") 1.32 + is(sources[2].url, "chrome://browser_dbg_addon5/content/testxul.js", "correct url for addon tab code") 1.33 + is(sources[2].label, "testxul.js", "correct label for addon tab code") 1.34 + 1.35 + // Load a new module and tab and check they appear in the list of sources 1.36 + Cu.import("resource://browser_dbg_addon5/test2.jsm", {}); 1.37 + let tab2 = yield addTab("chrome://browser_dbg_addon5/content/test2.xul"); 1.38 + 1.39 + groups = yield addonDebugger.getSourceGroups(); 1.40 + is(groups[0].name, "browser_dbg_addon5@tests.mozilla.org", "Add-on code should be the first group"); 1.41 + is(groups[1].name, "chrome://global", "XUL code should be the second group"); 1.42 + is(groups.length, 2, "Should be only two groups."); 1.43 + 1.44 + sources = groups[0].sources; 1.45 + is(sources.length, 5, "Should be five sources"); 1.46 + ok(sources[0].url.endsWith("/browser_dbg_addon5@tests.mozilla.org/bootstrap.js"), "correct url for bootstrap code") 1.47 + is(sources[0].label, "bootstrap.js", "correct label for bootstrap code") 1.48 + is(sources[1].url, "resource://browser_dbg_addon5/test.jsm", "correct url for addon code") 1.49 + is(sources[1].label, "test.jsm", "correct label for addon code") 1.50 + is(sources[2].url, "chrome://browser_dbg_addon5/content/testxul.js", "correct url for addon tab code") 1.51 + is(sources[2].label, "testxul.js", "correct label for addon tab code") 1.52 + is(sources[3].url, "resource://browser_dbg_addon5/test2.jsm", "correct url for addon code") 1.53 + is(sources[3].label, "test2.jsm", "correct label for addon code") 1.54 + is(sources[4].url, "chrome://browser_dbg_addon5/content/testxul2.js", "correct url for addon tab code") 1.55 + is(sources[4].label, "testxul2.js", "correct label for addon tab code") 1.56 + 1.57 + Cu.unload("resource://browser_dbg_addon5/test2.jsm"); 1.58 + yield addonDebugger.destroy(); 1.59 + yield removeTab(tab1); 1.60 + yield removeTab(tab2); 1.61 + yield removeAddon(addon); 1.62 + finish(); 1.63 + }); 1.64 +}