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,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)
Expand Down Expand Up @@ -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)

Expand Down
11 changes: 7 additions & 4 deletions include/NativeJSRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

namespace JsRuntime {

extern std::string DEFAULT_USER_AGENT;

struct MemoryStruct
{
MemoryStruct()
Expand Down Expand Up @@ -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<ApplicationDetails> getApplications();
void setExternalApplicationHandler(std::shared_ptr<IExternalApplicationHandler> handler);
void setExternalApplicationHandler(std::shared_ptr<IExternalApplicationHandler> handler);
std::string getBaseUserAgent();
private:
private:
bool downloadFile(std::string& url, MemoryStruct& chunk);
void processDevConsoleRequests();
void runDeveloperConsole(ModuleSettings moduleSettings);
Expand All @@ -154,6 +156,7 @@ namespace JsRuntime {
std::map<uint32_t, ApplicationData> mContextMap;
std::vector<ApplicationRequest> gPendingRequests;
std::shared_ptr<IExternalApplicationHandler> mExternalApplicationHandler;
std::string mBaseUserAgent;
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, mRenderer->getBaseUserAgent());
uint32_t id = mRenderer->createApplication(moduleSettings);
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,mRenderer->getBaseUserAgent());
uint32_t id = mRenderer->createApplication(moduleSettings);
std::ostringstream oss;
oss<< "ID : " << id;
result = oss.str();
Expand Down
12 changes: 7 additions & 5 deletions src/NativeJSRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
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,renderer->getBaseUserAgent());
uint32_t id = renderer->createApplication(moduleSettings);
renderer->runApplication(id, url);
//renderer->runJavaScript(id,url);
#if defined(NATIVEJS_DEVELOPER_MODE)
Expand Down