In pure Javascript probably not, this is because the native functions usually may not be written in Javascript completely, usually they are "interfaces", that are used to access an internal browser functionality or provide functionality for another feature on a level above.
This How to customize "Notification Web API" in Qt? is an example where I used Qtwebkit (an API that uses the engine Webkit) and had to rewrite it via C++ (Qt API actually) in order to customize Desktop notifications.
An example, still speaking of Qt, Webkit is possible to write its own functions, with QWebFrame::addToJavaScriptWindowObject
:
void Exemplo::setWebView( QWebView *view )
{
QWebPage *page = view->page();
frame = page->mainFrame();
define();
QObject::connect( frame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(define()) );
}
void Exemplo::define()
{
frame->addToJavaScriptWindowObject( QString("Exemplo"), this );
}
Of course the question has nothing to do with Qt, but what I want to explain is that in this way above I wrote an object like this:
window.Exemplo.foo();
Which will allow me to access functions of my C implementation++.
That is, there is no way to view the native code, because it is probably just an interface (in most cases/browsers), of course there may be some exception, but it will be one or the other.
So there really isn’t much reason to read the source code via Javascript, because there is "no" Javascript code there, these native functions probably only communicate with the browser/engine API and this triggers an existing browser functionality.
Now if you just want to find out, independent of Javascript, you will have to read the source code of the engine used by the browser (Webkit, Gecko, presto, Blink, Trident, etc) and the browsers also (Chromium, firefox, msedge) in its "versions" not compiled, which are probably written in C
or C++
Blink
Blink is the Fork of Webkit, used by Chrome and is also used in other browsers such as Opera, Vivaldi, etc..
That extend from this (line 33):
Gecko
Gecko is the "engine" used by Firefox or other Mozilla products, such as Thunderbird, i am not sure this is the appropriate repository, but it seems that the code you are looking for is this:
I found this repository: https://chromium.googlesource.com/v8/v8/+/6a7ec6a3bf779cdd41c66a768fd7a37195ed7b7f/src/js/ But it still seems to me to find a needle in the haystack
– MarceloBoni