Merge remote-tracking branch 'origin/dont-write-empty-dev-tools-extensions-file'
This commit is contained in:
commit
7ca09de386
3 changed files with 30 additions and 6 deletions
|
@ -54,12 +54,16 @@ app.on('will-quit', function() {
|
||||||
loadedExtensions = Object.keys(extensionInfoMap).map(function(key) {
|
loadedExtensions = Object.keys(extensionInfoMap).map(function(key) {
|
||||||
return extensionInfoMap[key].srcDirectory;
|
return extensionInfoMap[key].srcDirectory;
|
||||||
});
|
});
|
||||||
|
if (loadedExtensions.length > 0) {
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(path.dirname(loadedExtensionsPath));
|
fs.mkdirSync(path.dirname(loadedExtensionsPath));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Ignore error
|
// Ignore error
|
||||||
}
|
}
|
||||||
return fs.writeFileSync(loadedExtensionsPath, JSON.stringify(loadedExtensions));
|
fs.writeFileSync(loadedExtensionsPath, JSON.stringify(loadedExtensions));
|
||||||
|
} else {
|
||||||
|
fs.unlinkSync(loadedExtensionsPath);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Ignore error
|
// Ignore error
|
||||||
}
|
}
|
||||||
|
@ -70,7 +74,7 @@ app.once('ready', function() {
|
||||||
var BrowserWindow, chromeExtensionHandler, i, init, len, protocol, srcDirectory;
|
var BrowserWindow, chromeExtensionHandler, i, init, len, protocol, srcDirectory;
|
||||||
protocol = electron.protocol, BrowserWindow = electron.BrowserWindow;
|
protocol = electron.protocol, BrowserWindow = electron.BrowserWindow;
|
||||||
|
|
||||||
// Load persistented extensions.
|
// Load persisted extensions.
|
||||||
loadedExtensionsPath = path.join(app.getPath('userData'), 'DevTools Extensions');
|
loadedExtensionsPath = path.join(app.getPath('userData'), 'DevTools Extensions');
|
||||||
try {
|
try {
|
||||||
loadedExtensions = JSON.parse(fs.readFileSync(loadedExtensionsPath));
|
loadedExtensions = JSON.parse(fs.readFileSync(loadedExtensionsPath));
|
||||||
|
|
|
@ -8,6 +8,7 @@ const os = require('os');
|
||||||
const remote = require('electron').remote;
|
const remote = require('electron').remote;
|
||||||
const screen = require('electron').screen;
|
const screen = require('electron').screen;
|
||||||
|
|
||||||
|
const app = remote.require('electron').app;
|
||||||
const ipcMain = remote.require('electron').ipcMain;
|
const ipcMain = remote.require('electron').ipcMain;
|
||||||
const BrowserWindow = remote.require('electron').BrowserWindow;
|
const BrowserWindow = remote.require('electron').BrowserWindow;
|
||||||
|
|
||||||
|
@ -686,4 +687,20 @@ describe('browser-window module', function() {
|
||||||
}, 'Missing required channel argument');
|
}, 'Missing required channel argument');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('dev tool extensions', function () {
|
||||||
|
it('serializes the registered extensions on quit', function () {
|
||||||
|
var extensionName = 'foo';
|
||||||
|
var extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', extensionName);
|
||||||
|
var serializedPath = path.join(app.getPath('userData'), 'DevTools Extensions');
|
||||||
|
|
||||||
|
BrowserWindow.addDevToolsExtension(extensionPath);
|
||||||
|
app.emit('will-quit');
|
||||||
|
assert.deepEqual(JSON.parse(fs.readFileSync(serializedPath)), [extensionPath]);
|
||||||
|
|
||||||
|
BrowserWindow.removeDevToolsExtension(extensionName);
|
||||||
|
app.emit('will-quit');
|
||||||
|
assert.equal(fs.existsSync(serializedPath), false);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
3
spec/fixtures/devtools-extensions/foo/manifest.json
vendored
Normal file
3
spec/fixtures/devtools-extensions/foo/manifest.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"name": "foo"
|
||||||
|
}
|
Loading…
Reference in a new issue