diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h index f27493532..7b0f61428 100644 --- a/javascript/jsapi/binding.h +++ b/javascript/jsapi/binding.h @@ -45,8 +45,8 @@ JSObject *jsapi_InitClass_Location(JSContext *cx, JSObject *parent); JSObject *jsapi_new_Location(JSContext *cx, JSObject *window, JSObject *parent, - struct browser_window *bw, - nsurl *url); + nsurl *url, + html_content *htmlc); JSObject *jsapi_InitClass_Document(JSContext *cx, JSObject *parent); diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd index 72bc81482..f17190d0c 100644 --- a/javascript/jsapi/htmldocument.bnd +++ b/javascript/jsapi/htmldocument.bnd @@ -56,6 +56,7 @@ api finalise %{ } %} + getter location %{ if (!JSVAL_IS_VOID(JSAPI_PROP_RVAL(cx,vp))) { /* already created - return it */ @@ -64,10 +65,27 @@ getter location %{ jsret = jsapi_new_Location(cx, NULL, NULL, - private->htmlc->bw, - llcache_handle_get_url(private->htmlc->base.llcache)); + llcache_handle_get_url(private->htmlc->base.llcache), + private->htmlc); %} +getter URL %{ + jsval loc; + jsval jsstr = JSVAL_NULL; + if (JS_GetProperty(cx, obj, "location", &loc) == JS_TRUE) { + JS_GetProperty(cx, JSVAL_TO_OBJECT(loc), "href", &jsstr); + } + jsret = JSVAL_TO_STRING(jsstr); +%} + +getter documentURI %{ + jsval loc; + jsval jsstr = JSVAL_NULL; + if (JS_GetProperty(cx, obj, "location", &loc) == JS_TRUE) { + JS_GetProperty(cx, JSVAL_TO_OBJECT(loc), "href", &jsstr); + } + jsret = JSVAL_TO_STRING(jsstr); +%} getter cookie %{ char *cookie_str; diff --git a/javascript/jsapi/location.bnd b/javascript/jsapi/location.bnd index 32e38da93..32677d1b5 100644 --- a/javascript/jsapi/location.bnd +++ b/javascript/jsapi/location.bnd @@ -32,19 +32,27 @@ binding location { interface Location; /* Web IDL interface to generate */ - private "struct browser_window *" bw; private "nsurl *" url; + private "struct html_content *" htmlc; + + property unshared href; } operation reload %{ - browser_window_reload(private->bw, false); + browser_window_reload(private->htmlc->bw, false); %} getter href %{ char *url_s = NULL; size_t url_l; + + if (!JSVAL_IS_VOID(JSAPI_PROP_RVAL(cx,vp))) { + /* already created - return it */ + return JS_TRUE; + } + nsurl_get(private->url, NSURL_COMPLETE, &url_s, &url_l); if (url_s != NULL) { jsret = JS_NewStringCopyN(cx, url_s, url_l); diff --git a/test/js/document-url.html b/test/js/document-url.html new file mode 100644 index 000000000..2299b5775 --- /dev/null +++ b/test/js/document-url.html @@ -0,0 +1,31 @@ + +
+