/* * Copyright (c) 2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include namespace Web { namespace Bindings { NavigatorObject::NavigatorObject(JS::GlobalObject& global_object) : Object(*global_object.object_prototype()) { } void NavigatorObject::initialize(JS::GlobalObject& global_object) { auto& heap = this->heap(); auto* languages = JS::Array::create(global_object, 0); languages->indexed_properties().append(js_string(heap, "en-US")); // FIXME: All of these should be in Navigator's prototype and be native accessors define_property("appCodeName", js_string(heap, "Mozilla")); define_property("appName", js_string(heap, "Netscape")); define_property("appVersion", js_string(heap, "4.0")); define_property("language", languages->get(0)); define_property("languages", languages); define_property("platform", js_string(heap, "SerenityOS")); define_property("product", js_string(heap, "Gecko")); define_native_accessor("userAgent", user_agent_getter, {}); } NavigatorObject::~NavigatorObject() { } JS_DEFINE_NATIVE_FUNCTION(NavigatorObject::user_agent_getter) { return JS::js_string(vm, ResourceLoader::the().user_agent()); } } }