diff --git a/CHANGELOG.md b/CHANGELOG.md index e2de213..755b629 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.0.10](https://github.com/rdkcentral/rdkNativeScript/compare/1.0.9...1.0.10) + +- RDKEMW-9765 : [BUG_FIX]UserAgent string need to be aligned with browser for diff… [`#77`](https://github.com/rdkcentral/rdkNativeScript/pull/77) +- RDKEMW-9765 : [BUG_FIX]UserAgent string need to be aligned with browser for different agents [`881b332`](https://github.com/rdkcentral/rdkNativeScript/commit/881b332528ae114f0a9c2f767c8a1436154d380c) +- Merge tag '1.0.9' into develop [`b60efc0`](https://github.com/rdkcentral/rdkNativeScript/commit/b60efc01bf49975196c7a55aa3e6736af753916b) + #### [1.0.9](https://github.com/rdkcentral/rdkNativeScript/compare/1.0.8...1.0.9) -- RDK-59629 : UserAgent string need to be aligned with browser for diff… [`#74`](https://github.com/rdkcentral/rdkNativeScript/pull/74) -- RDK-59629 : UserAgent string need to be aligned with browser for different agents [`55af0ec`](https://github.com/rdkcentral/rdkNativeScript/commit/55af0ec4471fa402421f3dd29370712e23e452b9) +> 22 October 2025 + +- RDKEMW-59629 : UserAgent string need to be aligned with browser for diff… [`#74`](https://github.com/rdkcentral/rdkNativeScript/pull/74) +- RDKEMW-59629 : UserAgent string need to be aligned with browser for different agents [`55af0ec`](https://github.com/rdkcentral/rdkNativeScript/commit/55af0ec4471fa402421f3dd29370712e23e452b9) +- 1.0.9 release changelog updates [`85fcc69`](https://github.com/rdkcentral/rdkNativeScript/commit/85fcc6933d60d3b46da0fd144adb19f3d458575b) - Merge tag '1.0.8' into develop [`bad6257`](https://github.com/rdkcentral/rdkNativeScript/commit/bad62579572069c5a3f06bb70c0152022ddc7ce7) #### [1.0.8](https://github.com/rdkcentral/rdkNativeScript/compare/1.0.7...1.0.8) @@ -53,7 +62,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). > 7 September 2025 - RDKEMW-7489: Adding Href support [`#54`](https://github.com/rdkcentral/rdkNativeScript/pull/54) -- Ticket:RDKEMW-5556: Bug for terminateApplication [`#51`](https://github.com/rdkcentral/rdkNativeScript/pull/51) +- RDKEMW-5556: Bug for terminateApplication [`#51`](https://github.com/rdkcentral/rdkNativeScript/pull/51) - 1.0.4 release changelog updates [`2e56742`](https://github.com/rdkcentral/rdkNativeScript/commit/2e56742d0adda04fe61277fa0782e2b5b2dde19c) - Merge tag '1.0.3' into develop [`e15828d`](https://github.com/rdkcentral/rdkNativeScript/commit/e15828d5a330b072753e682f5c446b0f9ae14531) diff --git a/include/NativeJSRenderer.h b/include/NativeJSRenderer.h index d75e2b5..51fde0f 100644 --- a/include/NativeJSRenderer.h +++ b/include/NativeJSRenderer.h @@ -34,6 +34,8 @@ namespace JsRuntime { + extern std::string DEFAULT_USER_AGENT; + struct MemoryStruct { MemoryStruct() @@ -125,12 +127,12 @@ namespace JsRuntime { void setEnvForConsoleMode(ModuleSettings& moduleSettings); bool runApplication(uint32_t id, std::string url); bool runJavaScript(uint32_t id, std::string code); - uint32_t createApplication(ModuleSettings& moduleSettings, std::string userAgent) ; + uint32_t createApplication(ModuleSettings& moduleSettings, std::string userAgent = DEFAULT_USER_AGENT) ; bool terminateApplication(uint32_t id); std::list getApplications(); - void setExternalApplicationHandler(std::shared_ptr handler); + void setExternalApplicationHandler(std::shared_ptr handler); std::string getBaseUserAgent(); - private: + private: bool downloadFile(std::string& url, MemoryStruct& chunk); void processDevConsoleRequests(); void runDeveloperConsole(ModuleSettings moduleSettings); @@ -154,6 +156,7 @@ namespace JsRuntime { std::map mContextMap; std::vector gPendingRequests; std::shared_ptr mExternalApplicationHandler; - std::string mBaseUserAgent; + std::string mBaseUserAgent; + }; }; diff --git a/src/JSRuntimeServer.cpp b/src/JSRuntimeServer.cpp index 3269830..340a070 100644 --- a/src/JSRuntimeServer.cpp +++ b/src/JSRuntimeServer.cpp @@ -217,7 +217,7 @@ void JSRuntimeServer::onMessage(websocketpp::connection_hdl hdl, message_ptr msg std::string options = jParams.getString("moduleSettings", error); ModuleSettings moduleSettings; moduleSettings.fromString(options); - uint32_t id = mRenderer->createApplication(moduleSettings, mRenderer->getBaseUserAgent()); + uint32_t id = mRenderer->createApplication(moduleSettings); mRenderer->runApplication(id, url); std::ostringstream oss; oss<< "ID : " << id; @@ -237,7 +237,7 @@ void JSRuntimeServer::onMessage(websocketpp::connection_hdl hdl, message_ptr msg } ModuleSettings moduleSettings; moduleSettings.fromString(options); - uint32_t id = mRenderer->createApplication(moduleSettings,mRenderer->getBaseUserAgent()); + uint32_t id = mRenderer->createApplication(moduleSettings); std::ostringstream oss; oss<< "ID : " << id; result = oss.str(); diff --git a/src/NativeJSRenderer.cpp b/src/NativeJSRenderer.cpp index 1244f51..a7b71e6 100644 --- a/src/NativeJSRenderer.cpp +++ b/src/NativeJSRenderer.cpp @@ -54,6 +54,10 @@ using namespace JsRuntime; rtThreadQueue* gUIThreadQueue = NULL; #endif +namespace JsRuntime { + std::string DEFAULT_USER_AGENT = "Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15 "; +} + static size_t HeaderCallback(void *contents, size_t size, size_t nmemb, void *userp) { size_t downloadSize = size * nmemb; @@ -92,7 +96,7 @@ static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, voi return downloadSize; } -NativeJSRenderer::NativeJSRenderer(std::string waylandDisplay): mEngine(nullptr), mRunning(true), mEnableTestFileDOMSupport(false), mEmbedThunderJS(false), mEmbedRdkWebBridge(false), mEnableWebSocketServer(false), mContextMap(), mEssosInitialized(false), mConsoleMode(false) +NativeJSRenderer::NativeJSRenderer(std::string waylandDisplay): mEngine(nullptr), mRunning(true), mEnableTestFileDOMSupport(false), mEmbedThunderJS(false), mEmbedRdkWebBridge(false), mEnableWebSocketServer(false), mContextMap(), mEssosInitialized(false), mConsoleMode(false), mBaseUserAgent(DEFAULT_USER_AGENT) { if (waylandDisplay.size() > 0) { @@ -104,9 +108,6 @@ NativeJSRenderer::NativeJSRenderer(std::string waylandDisplay): mEngine(nullptr) const char* levelFromEnv = getenv("NATIVEJS_LOG_LEVEL"); - //setting the base userAgent value - mBaseUserAgent = "Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15 "; - // checking for ethan log env #ifdef USE_ETHANLOG NativeJSLogger::isEthanLogEnabled(); @@ -305,7 +306,8 @@ void NativeJSRenderer::createApplicationInternal(ApplicationRequest& appRequest) std::stringstream uagent; uagent << "window.navigator.userAgent = \"" << userAgent << "\";"; context->runScript(uagent.str().c_str(),true, userAgent, nullptr, true); - + + NativeJSLogger::log(INFO, "UserAgent set to : %s", userAgent.c_str()); NativeJSLogger::log(DEBUG, "Context created for ID: %d\n", id); if (mExternalApplicationHandler) { context->setExternalApplicationHandler(mExternalApplicationHandler); diff --git a/src/jsruntime.cpp b/src/jsruntime.cpp index ab2b70c..0f6390c 100644 --- a/src/jsruntime.cpp +++ b/src/jsruntime.cpp @@ -134,7 +134,7 @@ int main(int argc, char* argv[]) applicationThreads.emplace_back([renderer, url, &moduleSettings]() { NativeJSLogger::log(INFO, "Application URL is %s\n", (url.size() ? url.c_str() : "empty")); - uint32_t id = renderer->createApplication(moduleSettings,renderer->getBaseUserAgent()); + uint32_t id = renderer->createApplication(moduleSettings); renderer->runApplication(id, url); //renderer->runJavaScript(id,url); #if defined(NATIVEJS_DEVELOPER_MODE)