diff --git a/CHANGELOG.md b/CHANGELOG.md index 510de92..e2de213 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,23 +4,32 @@ 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.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) +- 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) +> 8 October 2025 + - RDKEMW-8952 : Switching between Xumo Fast Channels and Vipa activated… [`#71`](https://github.com/rdkcentral/rdkNativeScript/pull/71) - RDKEMW-8952 : Switching between Xumo Fast Channels and Vipa activated Channels [`505914d`](https://github.com/rdkcentral/rdkNativeScript/commit/505914dbfa6dbe842c7ec46e169ccca47ca6032b) +- 1.0.8 release changelog updates [`ca57a38`](https://github.com/rdkcentral/rdkNativeScript/commit/ca57a38905f7004614ded25722f1769e0f117ca0) - Merge tag '1.0.7' into develop [`d367c14`](https://github.com/rdkcentral/rdkNativeScript/commit/d367c14f8efa22be9632ba692ed658321402a0e3) #### [1.0.7](https://github.com/rdkcentral/rdkNativeScript/compare/1.0.6...1.0.7) > 30 September 2025 -- RDKEMW-8952 : Switching between Xumo Fast Channels and Vipa activated… [`#68`](https://github.com/rdkcentral/rdkNativeScript/pull/68) +- DELIA-68967 : Switching between Xumo Fast Channels and Vipa activated… [`#68`](https://github.com/rdkcentral/rdkNativeScript/pull/68) - RDKEMW-5610 : L1 test cases for jsruntime [`#66`](https://github.com/rdkcentral/rdkNativeScript/pull/66) - Deploy fossid_integration_stateless_diffscan_target_repo action [`#67`](https://github.com/rdkcentral/rdkNativeScript/pull/67) - Deploy cla action [`#40`](https://github.com/rdkcentral/rdkNativeScript/pull/40) - Update CODEOWNERS [`#63`](https://github.com/rdkcentral/rdkNativeScript/pull/63) - 1.0.7 release changelog updates [`0f3be4f`](https://github.com/rdkcentral/rdkNativeScript/commit/0f3be4fecad9213a4d86c828e978c29199e5d190) -- RDKEMW-8952 : Switching between Xumo Fast Channels and Vipa activated Channels [`228cf8b`](https://github.com/rdkcentral/rdkNativeScript/commit/228cf8bfdde6d7f7d991805193038b392bc0e89b) +- DELIA-68967 : Switching between Xumo Fast Channels and Vipa activated Channels [`228cf8b`](https://github.com/rdkcentral/rdkNativeScript/commit/228cf8bfdde6d7f7d991805193038b392bc0e89b) - Merge tag '1.0.6' into develop [`afdf341`](https://github.com/rdkcentral/rdkNativeScript/commit/afdf341c4f81e7019d76f207c7b428dbd0ffc00d) #### [1.0.6](https://github.com/rdkcentral/rdkNativeScript/compare/1.0.5...1.0.6) @@ -44,7 +53,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) -- RDKEMW-5556: Bug for terminateApplication [`#51`](https://github.com/rdkcentral/rdkNativeScript/pull/51) +- Ticket: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 e4d9fdc..d75e2b5 100644 --- a/include/NativeJSRenderer.h +++ b/include/NativeJSRenderer.h @@ -92,7 +92,7 @@ namespace JsRuntime { struct ApplicationRequest { - ApplicationRequest(uint32_t id, RequestType requestType, std::string url="", bool enableHttp=false, bool enableXHR=false, bool enableWebSocket=false, bool enableWebSocketEnhanced=false, bool enableFetch=false, bool enableJSDOM=false, bool enableWindow=false, bool enablePlayer=false): mId(id), mRequestType(requestType), mUrl(url), mEnableHttp(enableHttp), mEnableXHR(enableXHR), mEnableWebSocket(enableWebSocket), mEnableWebSocketEnhanced(enableWebSocketEnhanced), mEnableFetch(enableFetch), mEnableJSDOM(enableJSDOM), mEnableWindow(enableWindow), mEnablePlayer(enablePlayer) + ApplicationRequest(uint32_t id, RequestType requestType, std::string url="", bool enableHttp=false, bool enableXHR=false, bool enableWebSocket=false, bool enableWebSocketEnhanced=false, bool enableFetch=false, bool enableJSDOM=false, bool enableWindow=false, bool enablePlayer=false, std::string userAgent=""): mId(id), mRequestType(requestType), mUrl(url), mEnableHttp(enableHttp), mEnableXHR(enableXHR), mEnableWebSocket(enableWebSocket), mEnableWebSocketEnhanced(enableWebSocketEnhanced), mEnableFetch(enableFetch), mEnableJSDOM(enableJSDOM), mEnableWindow(enableWindow), mEnablePlayer(enablePlayer), mUserAgent(userAgent) { } uint32_t mId; @@ -106,6 +106,8 @@ namespace JsRuntime { bool mEnableJSDOM; bool mEnableWindow; bool mEnablePlayer; + std::string mUserAgent; + }; struct ApplicationData{ std::string url; @@ -123,10 +125,11 @@ 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) ; + uint32_t createApplication(ModuleSettings& moduleSettings, std::string userAgent) ; bool terminateApplication(uint32_t id); std::list getApplications(); void setExternalApplicationHandler(std::shared_ptr handler); + std::string getBaseUserAgent(); private: bool downloadFile(std::string& url, MemoryStruct& chunk); void processDevConsoleRequests(); @@ -151,5 +154,6 @@ namespace JsRuntime { std::map mContextMap; std::vector gPendingRequests; std::shared_ptr mExternalApplicationHandler; + std::string mBaseUserAgent; }; }; diff --git a/src/JSRuntimeServer.cpp b/src/JSRuntimeServer.cpp index 340a070..3269830 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); + uint32_t id = mRenderer->createApplication(moduleSettings, mRenderer->getBaseUserAgent()); 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); + uint32_t id = mRenderer->createApplication(moduleSettings,mRenderer->getBaseUserAgent()); std::ostringstream oss; oss<< "ID : " << id; result = oss.str(); diff --git a/src/NativeJSRenderer.cpp b/src/NativeJSRenderer.cpp index fbc852f..1244f51 100644 --- a/src/NativeJSRenderer.cpp +++ b/src/NativeJSRenderer.cpp @@ -103,6 +103,10 @@ 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(); @@ -214,12 +218,12 @@ uint32_t NativeJSRenderer::createApplicationIdentifier() return ret; } -uint32_t NativeJSRenderer::createApplication(ModuleSettings& moduleSettings) +uint32_t NativeJSRenderer::createApplication(ModuleSettings& moduleSettings, std::string userAgent) { uint32_t id=0; mUserMutex.lock(); id = createApplicationIdentifier(); - ApplicationRequest request(id, CREATE, "", moduleSettings.enableHttp, moduleSettings.enableXHR, moduleSettings.enableWebSocket, moduleSettings.enableWebSocketEnhanced, moduleSettings.enableFetch, moduleSettings.enableJSDOM, moduleSettings.enableWindow, moduleSettings.enablePlayer); + ApplicationRequest request(id, CREATE, "", moduleSettings.enableHttp, moduleSettings.enableXHR, moduleSettings.enableWebSocket, moduleSettings.enableWebSocketEnhanced, moduleSettings.enableFetch, moduleSettings.enableJSDOM, moduleSettings.enableWindow, moduleSettings.enablePlayer, userAgent); gPendingRequests.push_back(request); mUserMutex.unlock(); return id; @@ -289,7 +293,7 @@ void NativeJSRenderer::createApplicationInternal(ApplicationRequest& appRequest) settings.enableWindow = appRequest.mEnableWindow; settings.enablePlayer = appRequest.mEnablePlayer; uint32_t id= appRequest.mId; - + std::string userAgent = appRequest.mUserAgent; JavaScriptContextFeatures features(mEmbedThunderJS, mEmbedRdkWebBridge, mEnableWebSocketServer, settings); JavaScriptContext* context = new JavaScriptContext(features, "" , mEngine); if(NULL == context) @@ -297,7 +301,12 @@ void NativeJSRenderer::createApplicationInternal(ApplicationRequest& appRequest) NativeJSLogger::log(DEBUG, "Context not created for ID: %d\n", id); return ; } - NativeJSLogger::log(DEBUG, "Context created for ID: %d\n", id); + + std::stringstream uagent; + uagent << "window.navigator.userAgent = \"" << userAgent << "\";"; + context->runScript(uagent.str().c_str(),true, userAgent, nullptr, true); + + NativeJSLogger::log(DEBUG, "Context created for ID: %d\n", id); if (mExternalApplicationHandler) { context->setExternalApplicationHandler(mExternalApplicationHandler); } @@ -619,3 +628,9 @@ void NativeJSRenderer::setExternalApplicationHandler(std::shared_ptrcreateApplication(moduleSettings); + uint32_t id = renderer->createApplication(moduleSettings,renderer->getBaseUserAgent()); renderer->runApplication(id, url); //renderer->runJavaScript(id,url); #if defined(NATIVEJS_DEVELOPER_MODE)