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