Skip to content

Commit

Permalink
Support for navigator.languages (electron#12419)
Browse files Browse the repository at this point in the history
  • Loading branch information
nitsakh authored and sethlu committed May 3, 2018
1 parent 534ffef commit 718fbf1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions atom/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "base/values.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/printing/print_preview_message_handler.h"
#include "chrome/browser/printing/print_view_manager_basic.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
Expand Down Expand Up @@ -102,7 +103,6 @@ struct PrintSettings {
bool print_background;
base::string16 device_name;
};

} // namespace

namespace mate {
Expand Down Expand Up @@ -437,9 +437,11 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,

managed_web_contents()->GetView()->SetDelegate(this);

auto* prefs = web_contents->GetMutableRendererPrefs();
prefs->accept_languages = g_browser_process->GetApplicationLocale();

#if defined(OS_LINUX) || defined(OS_WIN)
// Update font settings.
auto* prefs = web_contents->GetMutableRendererPrefs();
CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params,
(gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr)));
prefs->should_antialias_text = params.antialiasing;
Expand Down
8 changes: 8 additions & 0 deletions spec/chromium-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ describe('chromium feature', () => {
})
})

describe('navigator.languages', (done) => {
it('should return the system locale only', () => {
let appLocale = app.getLocale()
assert.equal(navigator.languages.length, 1)
assert.equal(navigator.languages[0], appLocale)
})
})

describe('navigator.serviceWorker', () => {
it('should register for file scheme', (done) => {
w = new BrowserWindow({
Expand Down

0 comments on commit 718fbf1

Please sign in to comment.