@@ -34,6 +34,26 @@ function safeRequire(devtools, ...args) {
34
34
return { } ;
35
35
}
36
36
37
+ function safeGet ( devtools , ...args ) {
38
+ for ( var i = 0 ; i < args . length ; i ++ ) {
39
+ var url = args [ i ] ;
40
+ if ( url . startsWith ( "resource://" ) ) {
41
+ try {
42
+ return Cu [ "import" ] ( url , { } ) ;
43
+ }
44
+ catch ( err ) {
45
+ }
46
+ } else if ( url . startsWith ( "devtools/" ) ) {
47
+ try {
48
+ return devtools [ "require" ] ( url ) ;
49
+ }
50
+ catch ( err ) {
51
+ }
52
+ }
53
+ }
54
+ return { } ;
55
+ }
56
+
37
57
// DevTools
38
58
// See also: https://bugzilla.mozilla.org/show_bug.cgi?id=912121
39
59
const devtools = safeImport (
@@ -50,9 +70,17 @@ const DevToolsUtils = safeRequire(devtools,
50
70
const { NodeActor } = devtools [ "require" ] ( "devtools/server/actors/inspector" ) ;
51
71
const makeInfallible = DevToolsUtils . makeInfallible ;
52
72
53
- const { DebuggerServer } = devtools [ "require" ] ( "devtools/server/main" ) ;
54
- const protocol = devtools [ "require" ] ( "devtools/server/protocol" ) ;
55
- const { method, RetVal, ActorClass, Actor, Arg, types } = protocol ;
73
+ const Protocol = safeRequire ( devtools ,
74
+ "devtools/shared/protocol" ,
75
+ "devtools/server/protocol"
76
+ ) ;
77
+
78
+ const DebuggerServer = safeGet ( devtools ,
79
+ "devtools/server/main" ,
80
+ "resource://gre/modules/devtools/dbg-server.jsm"
81
+ ) . DebuggerServer ;
82
+
83
+ const { method, RetVal, ActorClass, Actor, Arg, types } = Protocol ;
56
84
57
85
// Make sure the DebuggerServer.ObjectActorPreviewers is initialized.
58
86
// See also: https://github.com/firebug/firequery/issues/32
0 commit comments