]> git.gir.st - VimFx.git/blob - extension/lib/workarounds.coffee
WIP: workarounds
[VimFx.git] / extension / lib / workarounds.coffee
1 config = require('./config')
2 prefs = require('./prefs')
3 utils = require('./utils')
4 vimfx = require('./vimfx')
5
6 sandbox = 'security.sandbox.content'
7
8 module.exports = [
9 {
10 name: 'Devtools stuck in normal mode'
11 desc: 'When blurring and refocusing the devtools, VimFx will not enter
12 ignore mode when focusing an input element. This workarounds sets
13 devtools.toolbox.content-frame to false.'
14 regressed_by: [1539979]
15 more_info: ['http://bugzil.la/1585747'] # bug we rely on to be open
16 is_applied: -> prefs.root.get('devtools.toolbox.content-frame') == false
17 is_required: ->
18 Cu.importGlobalProperties(['XMLHttpRequest'])
19 xhr = new XMLHttpRequest() # using XHR, as we need result synchronously
20 xhr.open(
21 'GET', 'resource://devtools/client/framework/toolbox-hosts.js', false
22 )
23 xhr.overrideMimeType('text/plain') # prevent non-fatal 'XML Parsing Error'
24 xhr.send()
25 return xhr.response.includes('devtools.toolbox.content-frame')
26 apply: -> prefs.root.set('devtools.toolbox.content-frame', false)
27 undo: -> prefs.root.set('devtools.toolbox.content-frame', null)
28 restart: false
29 },
30 {
31 name: 'frame.js needs sandbox whitelisting'
32 desc: 'The browser is preventing access to the config script. This
33 workaround will add it to the read-only whitelist
34 (security.sandbox.content.read_path_whitelist on non-OSX systems or
35 security.sandbox.content.mac.testing_read_path1 or 2 on OSX).'
36 regressed_by: [1288874]
37 # coffeelint: disable=max_line_length
38 more_info: ["#{vimfx.info?.homepageURL}/tree/master/documentation/config-file.md#on-process-sandboxing"]
39 # coffeelint: enable=max_line_length
40 is_applied: ->
41 dir = prefs.get('config_file_directory')
42 return true unless dir
43 dir = utils.expandPath(dir)
44 return not config.checkSandbox(dir)
45 is_required: ->
46 prefs.get('config_file_directory') != '' and
47 prefs.root.get("#{sandbox}.level") > 2
48 apply: ->
49 dir = prefs.get('config_file_directory')
50 return unless dir
51 seperator = if Services.appinfo.OS == 'WINNT' then '\\' else '/'
52 dir = utils.expandPath(dir) + seperator
53 if Services.appinfo.OS == 'Darwin'
54 if not prefs.root.get("#{sandbox}.mac.testing_read_path1")?
55 prefs.root.set("#{sandbox}.mac.testing_read_path1", dir)
56 else if not prefs.root.get("#{sandbox}.mac.testing_read_path2")?
57 prefs.root.set("#{sandbox}.mac.testing_read_path2", dir)
58 else
59 console.error('all whitelist prefs occupied, refusing to overwrite.')
60 else
61 val = prefs.root.get("#{sandbox}.read_path_whitelist").split(',')
62 val = val.filter((e) -> e != '')
63 val.push(dir)
64 prefs.root.set("#{sandbox}.read_path_whitelist", val.join(','))
65 undo: ->
66 dir = prefs.get('config_file_directory')
67 return unless dir
68 dir = utils.expandPath(dir)
69 if Services.appinfo.OS == 'Darwin'
70 if prefs.root.get("#{sandbox}.mac.testing_read_path1")?.startsWith(dir)
71 prefs.root.set("#{sandbox}.mac.testing_read_path1", null)
72 if prefs.root.get("#{sandbox}.mac.testing_read_path2")?.startsWith(dir)
73 prefs.root.set("#{sandbox}.mac.testing_read_path2", null)
74 else
75 val = prefs.root.get("#{sandbox}.read_path_whitelist").split(',')
76 val = val.filter((e) -> !e.startsWith(dir))
77 prefs.root.set("#{sandbox}.read_path_whitelist", val.join(','))
78 restart: false
79 },
80 {
81 name: 'Fission is enabled'
82 desc: 'VimFx is not fission compatible. This workaround flips the
83 fission.autostart pref off.'
84 regressed_by: []
85 more_info: ['http://bugzil.la/fission']
86 is_applied: -> prefs.root.get('fission.autostart') == false
87 is_required: -> prefs.root.get('fission.autostart') == true
88 apply: -> prefs.root.set('fission.autostart', false)
89 undo: -> prefs.root.set('fission.autostart', null)
90 restart: true
91 },
92 ]
Imprint / Impressum