From ed3358e501f4304da5152719ca4a0956fa7f4dd2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 18 Nov 2013 18:37:32 +0800 Subject: [PATCH] Add spec for custom uploading parameters. --- common/crash_reporter/crash_reporter.cc | 3 +++ common/v8_conversions.h | 5 +++-- spec/api/crash-reporter.coffee | 6 +++++- spec/fixtures/api/crash.html | 8 ++++++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/common/crash_reporter/crash_reporter.cc b/common/crash_reporter/crash_reporter.cc index f52f335ce0c8..c5765418bc44 100644 --- a/common/crash_reporter/crash_reporter.cc +++ b/common/crash_reporter/crash_reporter.cc @@ -36,6 +36,9 @@ void CrashReporter::Start(std::string product_name, void CrashReporter::SetUploadParameters(const StringMap& parameters) { upload_parameters_ = parameters; upload_parameters_["process_type"] = is_browser_ ? "browser" : "renderer"; + + // Setting platform dependent parameters. + SetUploadParameters(); } } // namespace crash_reporter diff --git a/common/v8_conversions.h b/common/v8_conversions.h index 378839a0c7ca..cd507231f631 100644 --- a/common/v8_conversions.h +++ b/common/v8_conversions.h @@ -53,8 +53,9 @@ struct FromV8Value { v8::Handle v8_dict = value_->ToObject(); v8::Handle v8_keys = v8_dict->GetOwnPropertyNames(); for (uint32_t i = 0; i < v8_keys->Length(); ++i) { - std::string key = FromV8Value(v8_keys->Get(i)); - dict[key] = std::string(FromV8Value(v8_dict->Get(i))); + v8::Handle v8_key = v8_keys->Get(i); + std::string key = FromV8Value(v8_key); + dict[key] = std::string(FromV8Value(v8_dict->Get(v8_key))); } return dict; diff --git a/spec/api/crash-reporter.coffee b/spec/api/crash-reporter.coffee index 415c2a0da453..86d0a0bb4819 100644 --- a/spec/api/crash-reporter.coffee +++ b/spec/api/crash-reporter.coffee @@ -13,13 +13,17 @@ describe 'crash-reporter module', -> server = http.createServer (req, res) -> form = new formidable.IncomingForm() form.parse req, (error, fields, files) -> + assert.equal fields['prod'], 'Atom-Shell Renderer' assert.equal fields['ver'], process.versions['atom-shell'] assert.equal fields['process_type'], 'renderer' + assert.equal fields['platform'], process.platform + assert.equal fields['extra1'], 'extra1' + assert.equal fields['extra2'], 'extra2' assert.equal files['upload_file_minidump']['name'], 'minidump.dmp' w.destroy() res.end() server.close() done() - server.listen 901007, '127.0.0.1', -> + server.listen 1127, '127.0.0.1', -> w.loadUrl 'file://' + path.join(fixtures, 'api', 'crash.html') diff --git a/spec/fixtures/api/crash.html b/spec/fixtures/api/crash.html index 88063bfb11bf..8933288a7c69 100644 --- a/spec/fixtures/api/crash.html +++ b/spec/fixtures/api/crash.html @@ -3,9 +3,13 @@