diff options
author | Vincent Sanders <vince@netsurf-browser.org> | 2012-11-03 17:37:59 +0000 |
---|---|---|
committer | Vincent Sanders <vince@netsurf-browser.org> | 2012-11-03 17:37:59 +0000 |
commit | 85c973f98648465ab065317f8e7db6153d093984 (patch) | |
tree | a38e78de2664042c56df277b91a4b7accdd4bdf7 | |
parent | e0f17a8d350c41f5dd304b7968a60bfec84c5b06 (diff) | |
download | netsurf-85c973f98648465ab065317f8e7db6153d093984.tar.gz netsurf-85c973f98648465ab065317f8e7db6153d093984.tar.bz2 |
add jsstring to jsval conversion macro that copes with null jsstrings
-rw-r--r-- | javascript/jsapi.h | 4 | ||||
-rw-r--r-- | test/js/dom-location.html | 13 |
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> |