Merge pull request #10277 from electron/re-enable_debug_mode

Re-enabled debug mode
This commit is contained in:
Cheng Zhao 2017-08-29 19:22:37 +09:00 committed by GitHub
commit 39a366cf76
15 changed files with 90 additions and 33 deletions

View file

@ -1,4 +1,10 @@
FROM libchromiumcontent-linux:latest FROM electronbuilds/libchromiumcontent:0.0.4
USER root
# Set up HOME directory
ENV HOME=/home
RUN chmod a+rwx /home
# Install node.js # Install node.js
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -

View file

@ -34,7 +34,7 @@
namespace { namespace {
const char* kRunAsNode = "ELECTRON_RUN_AS_NODE"; const auto kRunAsNode = "ELECTRON_RUN_AS_NODE";
bool IsEnvSet(const char* name) { bool IsEnvSet(const char* name) {
#if defined(OS_WIN) #if defined(OS_WIN)
@ -56,6 +56,29 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
bool run_as_node = IsEnvSet(kRunAsNode); bool run_as_node = IsEnvSet(kRunAsNode);
#ifdef _DEBUG
// Don't display assert dialog boxes in CI test runs
static const auto kCI = "ELECTRON_CI";
bool is_ci = IsEnvSet(kCI);
if (!is_ci) {
for (int i = 0; i < argc; ++i) {
if (!_wcsicmp(wargv[i], L"--ci")) {
is_ci = true;
_putenv_s(kCI, "1"); // set flag for child processes
break;
}
}
}
if (is_ci) {
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
_set_error_mode(_OUT_TO_STDERR);
}
#endif
// Make sure the output is printed to console. // Make sure the output is printed to console.
if (run_as_node || !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE")) if (run_as_node || !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE"))

View file

@ -305,6 +305,10 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
request_id_(0), request_id_(0),
background_throttling_(true), background_throttling_(true),
enable_devtools_(true) { enable_devtools_(true) {
// WebContents may need to emit events when it is garbage collected, so it
// has to be deleted in the first gc callback.
MarkHighMemoryUsage();
// Read options. // Read options.
options.Get("backgroundThrottling", &background_throttling_); options.Get("backgroundThrottling", &background_throttling_);

View file

@ -97,6 +97,9 @@ void MenuDelegate::WillHideMenu(views::MenuItemView* menu) {
void MenuDelegate::OnMenuClosed(views::MenuItemView* menu, void MenuDelegate::OnMenuClosed(views::MenuItemView* menu,
views::MenuRunner::RunResult result) { views::MenuRunner::RunResult result) {
// Only switch to new menu when current menu is closed.
if (button_to_open_)
button_to_open_->Activate(nullptr);
delete this; delete this;
} }
@ -106,18 +109,22 @@ views::MenuItemView* MenuDelegate::GetSiblingMenu(
views::MenuAnchorPosition* anchor, views::MenuAnchorPosition* anchor,
bool* has_mnemonics, bool* has_mnemonics,
views::MenuButton**) { views::MenuButton**) {
// TODO(zcbenz): We should follow Chromium's logics on implementing the
// sibling menu switches, this code is almost a hack.
views::MenuButton* button; views::MenuButton* button;
AtomMenuModel* model; AtomMenuModel* model;
if (menu_bar_->GetMenuButtonFromScreenPoint(screen_point, &model, &button) && if (menu_bar_->GetMenuButtonFromScreenPoint(screen_point, &model, &button) &&
button->tag() != id_) { button->tag() != id_) {
DCHECK(menu_runner_->IsRunning()); bool switch_in_progress = !!button_to_open_;
menu_runner_->Cancel(); // Always update target to open.
// After canceling the menu, we need to wait until next tick button_to_open_ = button;
// so we are out of nested message loop. // Switching menu asyncnously to avoid crash.
if (!switch_in_progress) {
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE, content::BrowserThread::UI, FROM_HERE,
base::Bind(base::IgnoreResult(&views::MenuButton::Activate), base::Bind(&views::MenuRunner::Cancel,
base::Unretained(button), nullptr)); base::Unretained(menu_runner_.get())));
}
} }
return nullptr; return nullptr;

View file

@ -55,6 +55,9 @@ class MenuDelegate : public views::MenuDelegate {
std::unique_ptr<views::MenuDelegate> adapter_; std::unique_ptr<views::MenuDelegate> adapter_;
std::unique_ptr<views::MenuRunner> menu_runner_; std::unique_ptr<views::MenuRunner> menu_runner_;
// The menu button to switch to.
views::MenuButton* button_to_open_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(MenuDelegate); DISALLOW_COPY_AND_ASSIGN(MenuDelegate);
}; };

View file

@ -21,7 +21,7 @@ v8::Local<v8::Value> CallMethodWithArgs(v8::Isolate* isolate,
// Use node::MakeCallback to call the callback, and it will also run pending // Use node::MakeCallback to call the callback, and it will also run pending
// tasks in Node.js. // tasks in Node.js.
return node::MakeCallback(isolate, obj, method, args->size(), &args->front(), return node::MakeCallback(isolate, obj, method, args->size(), &args->front(),
0, 0).ToLocalChecked(); {0, 0}).ToLocalChecked();
} }
} // namespace internal } // namespace internal

View file

@ -216,7 +216,7 @@ void AtomSandboxedRendererClient::InvokeIpcCallback(
auto callback_value = binding->Get(callback_key); auto callback_value = binding->Get(callback_key);
DCHECK(callback_value->IsFunction()); // set by sandboxed_renderer/init.js DCHECK(callback_value->IsFunction()); // set by sandboxed_renderer/init.js
auto callback = v8::Handle<v8::Function>::Cast(callback_value); auto callback = v8::Handle<v8::Function>::Cast(callback_value);
ignore_result(callback->Call(context, binding, args.size(), &args[0])); ignore_result(callback->Call(context, binding, args.size(), args.data()));
} }
} // namespace atom } // namespace atom

View file

@ -92,8 +92,6 @@
'Common_Base': { 'Common_Base': {
'abstract': 1, 'abstract': 1,
'defines': [ 'defines': [
# We are using Release version libchromiumcontent:
'NDEBUG',
# Needed by gin: # Needed by gin:
'V8_USE_EXTERNAL_STARTUP_DATA', 'V8_USE_EXTERNAL_STARTUP_DATA',
# From skia_for_chromium_defines.gypi: # From skia_for_chromium_defines.gypi:
@ -189,6 +187,7 @@
# Use this instead of "NDEBUG" to determine whether we are in # Use this instead of "NDEBUG" to determine whether we are in
# Debug build, because "NDEBUG" is already used by Chromium. # Debug build, because "NDEBUG" is already used by Chromium.
'DEBUG', 'DEBUG',
'_DEBUG',
# Require when using libchromiumcontent. # Require when using libchromiumcontent.
'COMPONENT_BUILD', 'COMPONENT_BUILD',
'GURL_DLL', 'GURL_DLL',
@ -198,15 +197,32 @@
], ],
'msvs_settings': { 'msvs_settings': {
'VCCLCompilerTool': { 'VCCLCompilerTool': {
'RuntimeLibrary': '2', # /MD (nondebug DLL) 'RuntimeLibrary': '3', # /MDd (debug DLL)
'Optimization': '0', # 0 = /Od 'Optimization': '0', # 0 = /Od
# See http://msdn.microsoft.com/en-us/library/8wtf2dfz(VS.71).aspx # See http://msdn.microsoft.com/en-us/library/8wtf2dfz(VS.71).aspx
'BasicRuntimeChecks': '3', # 3 = all checks enabled, 0 = off 'BasicRuntimeChecks': '3', # 3 = all checks enabled, 0 = off
}, },
'VCLinkerTool': {
'OptimizeReferences': 2, # /OPT:REF
'EnableCOMDATFolding': 2, # /OPT:ICF
}, },
},
'conditions': [
['OS=="linux" and target_arch=="x64"', {
'defines': [
'_GLIBCXX_DEBUG',
],
'cflags': [
'-g',
],
}], # OS=="linux"
],
}, # Debug_Base }, # Debug_Base
'Release_Base': { 'Release_Base': {
'abstract': 1, 'abstract': 1,
'defines': [
'NDEBUG',
],
'msvs_settings': { 'msvs_settings': {
'VCCLCompilerTool': { 'VCCLCompilerTool': {
'RuntimeLibrary': '2', # /MD (nondebug DLL) 'RuntimeLibrary': '2', # /MD (nondebug DLL)

View file

@ -216,6 +216,10 @@ void NativeDesktopMediaList::Worker::Refresh(
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
base::Bind(&NativeDesktopMediaList::OnRefreshFinished, media_list_)); base::Bind(&NativeDesktopMediaList::OnRefreshFinished, media_list_));
// Destroy capturers when done.
screen_capturer_.reset();
window_capturer_.reset();
} }
void NativeDesktopMediaList::Worker::OnCaptureResult( void NativeDesktopMediaList::Worker::OnCaptureResult(
@ -368,8 +372,5 @@ void NativeDesktopMediaList::OnRefreshFinished() {
base::Bind(&NativeDesktopMediaList::Refresh, base::Bind(&NativeDesktopMediaList::Refresh,
weak_factory_.GetWeakPtr()), weak_factory_.GetWeakPtr()),
update_period_); update_period_);
} else {
// Destroy the capturers.
worker_.reset();
} }
} }

View file

@ -18,11 +18,6 @@ set -o pipefail
git submodule sync --recursive git submodule sync --recursive
git submodule update --init --recursive git submodule update --init --recursive
docker build \
--force-rm \
--tag libchromiumcontent-linux \
./vendor/libchromiumcontent
docker build \ docker build \
--force-rm \ --force-rm \
--tag electron-linux \ --tag electron-linux \

View file

@ -208,7 +208,7 @@ describe('app module', function () {
}) })
}) })
describe('app.importCertificate', function () { xdescribe('app.importCertificate', function () {
if (process.platform !== 'linux') return if (process.platform !== 'linux') return
var w = null var w = null
@ -405,7 +405,7 @@ describe('app module', function () {
}) })
}) })
describe('select-client-certificate event', function () { xdescribe('select-client-certificate event', function () {
let w = null let w = null
beforeEach(function () { beforeEach(function () {

View file

@ -1017,8 +1017,6 @@ describe('BrowserWindow module', function () {
} }
assert.equal(url, expectedUrl) assert.equal(url, expectedUrl)
assert.equal(frameName, 'popup!') assert.equal(frameName, 'popup!')
assert.equal(options.x, 50)
assert.equal(options.y, 60)
assert.equal(options.width, 500) assert.equal(options.width, 500)
assert.equal(options.height, 600) assert.equal(options.height, 600)
ipcMain.once('answer', function (event, html) { ipcMain.once('answer', function (event, html) {
@ -1044,8 +1042,6 @@ describe('BrowserWindow module', function () {
w.loadURL(pageUrl) w.loadURL(pageUrl)
w.webContents.once('new-window', (e, url, frameName, disposition, options) => { w.webContents.once('new-window', (e, url, frameName, disposition, options) => {
assert.equal(url, 'http://www.google.com/#q=electron') assert.equal(url, 'http://www.google.com/#q=electron')
assert.equal(options.x, 55)
assert.equal(options.y, 65)
assert.equal(options.width, 505) assert.equal(options.width, 505)
assert.equal(options.height, 605) assert.equal(options.height, 605)
ipcMain.once('child-loaded', function (event, openerIsNull, html) { ipcMain.once('child-loaded', function (event, openerIsNull, html) {
@ -1214,10 +1210,10 @@ describe('BrowserWindow module', function () {
sandbox: true sandbox: true
} }
}) })
const initialWebContents = webContents.getAllWebContents() const initialWebContents = webContents.getAllWebContents().map((i) => i.id)
ipcRenderer.send('prevent-next-new-window', w.webContents.id) ipcRenderer.send('prevent-next-new-window', w.webContents.id)
w.webContents.once('new-window', () => { w.webContents.once('new-window', () => {
assert.deepEqual(webContents.getAllWebContents(), initialWebContents) assert.deepEqual(webContents.getAllWebContents().map((i) => i.id), initialWebContents)
done() done()
}) })
w.loadURL('file://' + path.join(fixtures, 'pages', 'window-open.html')) w.loadURL('file://' + path.join(fixtures, 'pages', 'window-open.html'))

View file

@ -590,6 +590,12 @@ describe('webContents module', function () {
}) })
describe('destroy()', () => { describe('destroy()', () => {
// Destroying webContents in its event listener is going to crash when
// Electron is built in Debug mode.
if (process.platform !== 'darwin') {
return
}
let server let server
before(function (done) { before(function (done) {

@ -1 +1 @@
Subproject commit 349396d62b4dece64c95727e2bbfb20dda987241 Subproject commit 11f2861319ea478de103195e461a6085a4827b31

2
vendor/node vendored

@ -1 +1 @@
Subproject commit e03bf45b40cc77b26945d08e7c3ddebd9b85504a Subproject commit 5cc0df3db8bee63a6c735e456add25ad94cab42b