Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down
8 changes: 6 additions & 2 deletions include/NativeJSRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -106,6 +106,8 @@ namespace JsRuntime {
bool mEnableJSDOM;
bool mEnableWindow;
bool mEnablePlayer;
std::string mUserAgent;

};
struct ApplicationData{
std::string url;
Expand All @@ -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<ApplicationDetails> getApplications();
void setExternalApplicationHandler(std::shared_ptr<IExternalApplicationHandler> handler);
std::string getBaseUserAgent();
private:
bool downloadFile(std::string& url, MemoryStruct& chunk);
void processDevConsoleRequests();
Expand All @@ -151,5 +154,6 @@ namespace JsRuntime {
std::map<uint32_t, ApplicationData> mContextMap;
std::vector<ApplicationRequest> gPendingRequests;
std::shared_ptr<IExternalApplicationHandler> mExternalApplicationHandler;
std::string mBaseUserAgent;
};
};
4 changes: 2 additions & 2 deletions src/JSRuntimeServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
23 changes: 19 additions & 4 deletions src/NativeJSRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -289,15 +293,20 @@ 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)
{
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);
}
Expand Down Expand Up @@ -619,3 +628,9 @@ void NativeJSRenderer::setExternalApplicationHandler(std::shared_ptr<IExternalAp
{
mExternalApplicationHandler = handler;
}

std::string NativeJSRenderer::getBaseUserAgent()
{
return mBaseUserAgent;
}

2 changes: 1 addition & 1 deletion src/jsruntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
uint32_t id = renderer->createApplication(moduleSettings,renderer->getBaseUserAgent());
renderer->runApplication(id, url);
//renderer->runJavaScript(id,url);
#if defined(NATIVEJS_DEVELOPER_MODE)
Expand Down