From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/omnavigator.c | 38 ++++++++++++++++++++++++++++++++++++-- dlls/mshtml/tests/dom.c | 4 ++++ dlls/mshtml/tests/es5.js | 8 +++++++- 3 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/omnavigator.c b/dlls/mshtml/omnavigator.c index 9706643f776..4320836b4f6 100644 --- a/dlls/mshtml/omnavigator.c +++ b/dlls/mshtml/omnavigator.c @@ -1946,8 +1946,42 @@ static HRESULT WINAPI HTMLPerformance_toString(IHTMLPerformance *iface, BSTR *st static HRESULT WINAPI HTMLPerformance_toJSON(IHTMLPerformance *iface, VARIANT *var) { HTMLPerformance *This = impl_from_IHTMLPerformance(iface); - FIXME("(%p)->(%p)\n", This, var); - return E_NOTIMPL; + IWineJSDispatch *json; + HRESULT hres; + VARIANT v; + + TRACE("(%p)->(%p)\n", This, var); + + if(!This->window->jscript) + return E_UNEXPECTED; + + if(!var) + return S_OK; + + hres = IWineJScript_CreateObject(This->window->jscript, &json); + if(FAILED(hres)) + return hres; + + hres = IHTMLPerformanceNavigation_toJSON(This->navigation, &v); + if(SUCCEEDED(hres)) { + hres = IWineJSDispatch_DefineProperty(json, L"navigation", PROPF_WRITABLE | PROPF_ENUMERABLE | PROPF_CONFIGURABLE, &v); + VariantClear(&v); + if(SUCCEEDED(hres)) { + hres = IHTMLPerformanceTiming_toJSON(This->timing, &v); + if(SUCCEEDED(hres)) { + hres = IWineJSDispatch_DefineProperty(json, L"timing", PROPF_WRITABLE | PROPF_ENUMERABLE | PROPF_CONFIGURABLE, &v); + VariantClear(&v); + } + } + } + if(FAILED(hres)) { + IWineJSDispatch_Release(json); + return hres; + } + + V_VT(var) = VT_DISPATCH; + V_DISPATCH(var) = (IDispatch*)json; + return hres; }
static const IHTMLPerformanceVtbl HTMLPerformanceVtbl = { diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 9778a5b1ad8..7250ffea636 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -12266,6 +12266,10 @@ static void test_quirks_mode_perf_toJSON(IHTMLDocument2 *doc) ok(perf != NULL, "performance is NULL\n"); VariantClear(&var);
+ hres = IHTMLPerformance_toJSON(perf, &var); + ok(hres == E_UNEXPECTED, "toJSON() returned: %08lx\n", hres); + ok(V_VT(&var) == VT_EMPTY, "V_VT(toJSON()) = %d\n", V_VT(&var)); + hres = IHTMLPerformance_get_navigation(perf, &nav); ok(hres == S_OK, "get_navigation failed: %08lx\n", hres); ok(nav != NULL, "performance.navigation is NULL\n"); diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index 347108e5810..6a3f24a265f 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -2595,7 +2595,7 @@ sync_test("functions scope", function() { });
sync_test("perf toJSON", function() { - var json, objs = [ performance.navigation, performance.timing ]; + var json, objs = [ performance, performance.navigation, performance.timing ]; var non_props = [ "constructor", "TYPE_BACK_FORWARD", "TYPE_NAVIGATE", "TYPE_RELOAD", "TYPE_RESERVED" ];
for(var i = 0; i < objs.length; i++) { @@ -2640,6 +2640,12 @@ sync_test("perf toJSON", function() { ok(json.hasOwnProperty(prop), name + ".toJSON() does not have " + prop + " after delete"); Object.defineProperty(proto, prop, desc); } + + json = performance.toJSON(); + ok(typeof json.navigation === "object", "JSON'd performance's navigation type = " + typeof json.navigation); + ok(typeof json.navigation.redirectCount === "number", "JSON'd performance's navigation.redirectCount type = " + typeof json.navigation.redirectCount); + ok(Object.getPrototypeOf(json.navigation) === Object.prototype, "JSON'd performance's navigation prototype != Object.prototype"); + ok(!("toJSON" in json.navigation), "toJSON in JSON'd performance's navigation"); });
sync_test("console", function() {