summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--javascript/duktape/Navigator.bnd76
-rw-r--r--javascript/duktape/Window.bnd21
-rw-r--r--javascript/duktape/netsurf.bnd1
-rw-r--r--test/js/index.html6
-rw-r--r--test/js/navigator-enumerate.html26
5 files changed, 130 insertions, 0 deletions
diff --git a/javascript/duktape/Navigator.bnd b/javascript/duktape/Navigator.bnd
new file mode 100644
index 000000000..577ac29f0
--- /dev/null
+++ b/javascript/duktape/Navigator.bnd
@@ -0,0 +1,76 @@
+/* Navigator binding for browser using duktape and libdom
+ *
+ * Copyright 2015 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
+
+method Navigator::taintEnabled()
+%{
+ duk_push_boolean(ctx, false);
+ return 1;
+%}
+
+getter Navigator::appCodeName()
+%{
+ duk_push_string(ctx, "Mozilla");
+ return 1;
+%}
+
+getter Navigator::appName()
+%{
+ duk_push_string(ctx, "Netscape");
+ return 1;
+%}
+
+getter Navigator::appVersion()
+%{
+ duk_push_string(ctx, "3.4");
+ return 1;
+%}
+
+getter Navigator::platform()
+%{
+ duk_push_string(ctx, NULL);
+ return 1;
+%}
+
+getter Navigator::product()
+%{
+ duk_push_string(ctx, "Gecko");
+ return 1;
+%}
+
+getter Navigator::productSub()
+%{
+ duk_push_string(ctx, "20100101");
+ return 1;
+%}
+
+getter Navigator::vendor()
+%{
+ duk_push_string(ctx, NULL);
+ return 1;
+%}
+
+getter Navigator::vendorSub()
+%{
+ duk_push_string(ctx, NULL);
+ return 1;
+%}
+
+getter Navigator::cookieEnabled()
+%{
+ duk_push_boolean(ctx, false);
+ return 1;
+%}
+
+/* indicate there is no plugin for java installed */
+getter Navigator::javaEnabled()
+%{
+ duk_push_boolean(ctx, false);
+ return 1;
+%}
diff --git a/javascript/duktape/Window.bnd b/javascript/duktape/Window.bnd
index 81f605931..af62eb711 100644
--- a/javascript/duktape/Window.bnd
+++ b/javascript/duktape/Window.bnd
@@ -95,3 +95,24 @@ getter Window::location()
}
return 1;
%}
+
+getter Window::navigator()
+%{
+ duk_push_this(ctx);
+ duk_get_prop_string(ctx, -1, MAGIC(Navigator));
+ if (duk_is_undefined(ctx, -1)) {
+ duk_pop(ctx);
+
+ if (dukky_create_object(ctx,
+ PROTO_NAME(NAVIGATOR),
+ 0) != DUK_EXEC_SUCCESS) {
+ duk_error(ctx,
+ DUK_ERR_ERROR,
+ "Unable to create navigator object");
+ return 0;
+ }
+ duk_dup(ctx, -1);
+ duk_put_prop_string(ctx, -3, MAGIC(Navigator));
+ }
+ return 1;
+%}
diff --git a/javascript/duktape/netsurf.bnd b/javascript/duktape/netsurf.bnd
index 91133caf7..f9148ee15 100644
--- a/javascript/duktape/netsurf.bnd
+++ b/javascript/duktape/netsurf.bnd
@@ -60,6 +60,7 @@ struct dom_html_br_element;
#include "Element.bnd"
#include "HTMLCollection.bnd"
#include "Location.bnd"
+#include "Navigator.bnd"
/* specialisations of html_element */
init HTMLUnknownElement(struct dom_html_element *html_unknown_element::html_element);
diff --git a/test/js/index.html b/test/js/index.html
index 38a59a6be..8602a8159 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -35,6 +35,12 @@
<li><a href="location-assign.html">assign</a> should navigate to enumeration with page in history</li>
<li><a href="location-replace.html">replace</a> should navigate to enumeration without page in history.</li>
<li><a href="location-href.html">href</a> should navigate to enumeration with page in history</li>
+<li><a href="location-putforwards.html">href</a> should navigate to enumeration using putforwards on location</li>
+</ul>
+
+<h2>Navigator</h2>
+<ul>
+<li><a href="navigator-enumerate.html">Enumerate members</a></li>
</ul>
diff --git a/test/js/navigator-enumerate.html b/test/js/navigator-enumerate.html
new file mode 100644
index 000000000..d3203ac16
--- /dev/null
+++ b/test/js/navigator-enumerate.html
@@ -0,0 +1,26 @@
+<html>
+<head>
+<title>navigator interface enumeration</title>
+<link rel="stylesheet" type="text/css" href="tst.css">
+</head>
+<body>
+<h1>navigator interface enumeration</h1>
+
+<script>
+function output(x,y) {
+ document.body.appendChild(document.createTextNode(x));
+ document.body.appendChild(document.createTextNode("("));
+ if (y != undefined) {
+ document.body.appendChild(document.createTextNode(y.length));
+ }
+ document.body.appendChild(document.createTextNode(") = "));
+ document.body.appendChild(document.createTextNode(y));
+ document.body.appendChild(document.createElement('br'));
+}
+
+for(var key in navigator) {
+ output(key, navigator[key]);
+}
+</script>
+</body>
+</html>