summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--javascript/jsapi.h4
-rw-r--r--test/js/dom-location.html13
2 files changed, 17 insertions, 0 deletions
diff --git a/javascript/jsapi.h b/javascript/jsapi.h
index e7c10c139..61baa5ce1 100644
--- a/javascript/jsapi.h
+++ b/javascript/jsapi.h
@@ -94,6 +94,8 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
outchar = JS_GetStringBytes(injsstring); \
outlen = strlen(outchar)
+/* string type cast */
+#define JSAPI_STRING_TO_JSVAL(str) ((str == NULL)?JSVAL_NULL:STRING_TO_JSVAL(str))
#else /* #if JS_VERSION <= 180 */
@@ -152,6 +154,8 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
JS_EncodeStringToBuffer(injsstring, outchar, outlen); \
outchar[outlen] = '\0'
+/* string type cast */
+#define JSAPI_STRING_TO_JSVAL(str) ((str == NULL)?JSVAL_NULL:STRING_TO_JSVAL(str))
#endif
diff --git a/test/js/dom-location.html b/test/js/dom-location.html
new file mode 100644
index 000000000..bbd78d80b
--- /dev/null
+++ b/test/js/dom-location.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+<title>Assign window.lately</title>
+<link rel="stylesheet" type="text/css" href="tst.css">
+</head>
+<body>
+<h1>Assign window.lately</h1>
+<p>location: <script>document.write(location);</script>
+<p>location.protocol: <script>document.write(location.protocol);</script>
+<p>equivalence <script>document.write(location.protocol === 'http:');</script>
+<p>assignement<script>window.lately = (location.protocol === 'http:');</script>
+</body>
+</html>