Commit 2865a5f1 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Implement location.reload().

parent 0e71100e
...@@ -582,8 +582,21 @@ static HRESULT WINAPI HTMLLocation_get_hash(IHTMLLocation *iface, BSTR *p) ...@@ -582,8 +582,21 @@ static HRESULT WINAPI HTMLLocation_get_hash(IHTMLLocation *iface, BSTR *p)
static HRESULT WINAPI HTMLLocation_reload(IHTMLLocation *iface, VARIANT_BOOL flag) static HRESULT WINAPI HTMLLocation_reload(IHTMLLocation *iface, VARIANT_BOOL flag)
{ {
HTMLLocation *This = impl_from_IHTMLLocation(iface); HTMLLocation *This = impl_from_IHTMLLocation(iface);
FIXME("(%p)->(%x)\n", This, flag);
return E_NOTIMPL; TRACE("(%p)->(%x)\n", This, flag);
if(!This->window) {
FIXME("No window available\n");
return E_FAIL;
}
/* reload is supposed to fail if called from a script with different origin, but IE doesn't care */
if(!is_main_content_window(This->window->base.outer_window)) {
FIXME("Unsupported on iframe\n");
return E_NOTIMPL;
}
return reload_page(This->window->base.outer_window);
} }
static HRESULT WINAPI HTMLLocation_replace(IHTMLLocation *iface, BSTR bstr) static HRESULT WINAPI HTMLLocation_replace(IHTMLLocation *iface, BSTR bstr)
......
...@@ -1094,6 +1094,7 @@ HRESULT async_start_doc_binding(HTMLOuterWindow*,HTMLInnerWindow*) DECLSPEC_HIDD ...@@ -1094,6 +1094,7 @@ HRESULT async_start_doc_binding(HTMLOuterWindow*,HTMLInnerWindow*) DECLSPEC_HIDD
void abort_window_bindings(HTMLInnerWindow*) DECLSPEC_HIDDEN; void abort_window_bindings(HTMLInnerWindow*) DECLSPEC_HIDDEN;
void set_download_state(HTMLDocumentObj*,int) DECLSPEC_HIDDEN; void set_download_state(HTMLDocumentObj*,int) DECLSPEC_HIDDEN;
void call_docview_84(HTMLDocumentObj*) DECLSPEC_HIDDEN; void call_docview_84(HTMLDocumentObj*) DECLSPEC_HIDDEN;
HRESULT reload_page(HTMLOuterWindow*) DECLSPEC_HIDDEN;
void set_ready_state(HTMLOuterWindow*,READYSTATE) DECLSPEC_HIDDEN; void set_ready_state(HTMLOuterWindow*,READYSTATE) DECLSPEC_HIDDEN;
HRESULT get_readystate_string(READYSTATE,BSTR*) DECLSPEC_HIDDEN; HRESULT get_readystate_string(READYSTATE,BSTR*) DECLSPEC_HIDDEN;
......
...@@ -449,10 +449,23 @@ static void refresh_destr(task_t *_task) ...@@ -449,10 +449,23 @@ static void refresh_destr(task_t *_task)
free(task); free(task);
} }
HRESULT reload_page(HTMLOuterWindow *window)
{
refresh_task_t *task;
task = malloc(sizeof(*task));
if(!task)
return E_OUTOFMEMORY;
IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
task->window = window;
return push_task(&task->header, refresh_proc, refresh_destr, window->task_magic);
}
static HRESULT exec_refresh(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_refresh(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
HTMLDocumentObj *doc_obj; HTMLDocumentObj *doc_obj;
refresh_task_t *task;
HRESULT hres; HRESULT hres;
TRACE("(%p)->(%ld %s %p)\n", doc, nCmdexecopt, debugstr_variant(pvaIn), pvaOut); TRACE("(%p)->(%ld %s %p)\n", doc, nCmdexecopt, debugstr_variant(pvaIn), pvaOut);
...@@ -478,14 +491,7 @@ static HRESULT exec_refresh(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *p ...@@ -478,14 +491,7 @@ static HRESULT exec_refresh(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *p
if(!doc->outer_window) if(!doc->outer_window)
return E_UNEXPECTED; return E_UNEXPECTED;
task = malloc(sizeof(*task)); return reload_page(doc->outer_window);
if(!task)
return E_OUTOFMEMORY;
IHTMLWindow2_AddRef(&doc->outer_window->base.IHTMLWindow2_iface);
task->window = doc->outer_window;
return push_task(&task->header, refresh_proc, refresh_destr, doc->outer_window->task_magic);
} }
static HRESULT exec_stop(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_stop(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
......
...@@ -1142,6 +1142,7 @@ static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, D ...@@ -1142,6 +1142,7 @@ static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, D
case 3000030: case 3000030:
case 3000031: case 3000031:
case 3000032: case 3000032:
case 3000033:
/* TODO */ /* TODO */
return S_OK; return S_OK;
} }
...@@ -6399,6 +6400,24 @@ static void test_refresh(IHTMLDocument2 *doc) ...@@ -6399,6 +6400,24 @@ static void test_refresh(IHTMLDocument2 *doc)
test_download(DWL_VERBDONE|DWL_HTTP|DWL_ONREADY_LOADING|DWL_REFRESH|DWL_EX_GETHOSTINFO); test_download(DWL_VERBDONE|DWL_HTTP|DWL_ONREADY_LOADING|DWL_REFRESH|DWL_EX_GETHOSTINFO);
} }
static void test_reload(IHTMLDocument2 *doc)
{
IHTMLLocation *location;
HRESULT hres;
trace("Reload...\n");
location = NULL;
hres = IHTMLDocument2_get_location(doc, &location);
ok(hres == S_OK, "get_location failed: %08lx\n", hres);
ok(location != NULL, "location == NULL\n");
hres = IHTMLLocation_reload(location, VARIANT_FALSE);
IHTMLLocation_Release(location);
test_download(DWL_VERBDONE|DWL_HTTP|DWL_ONREADY_LOADING|DWL_REFRESH|DWL_EX_GETHOSTINFO);
}
static void test_open_window(IHTMLDocument2 *doc, BOOL do_block) static void test_open_window(IHTMLDocument2 *doc, BOOL do_block)
{ {
IHTMLWindow2 *window, *new_window; IHTMLWindow2 *window, *new_window;
...@@ -8216,6 +8235,7 @@ static void test_HTMLDocument_http(BOOL with_wbapp) ...@@ -8216,6 +8235,7 @@ static void test_HTMLDocument_http(BOOL with_wbapp)
test_put_href(doc, FALSE, L"#test", L"http://test.winehq.org/tests/winehq_snapshot/#test", FALSE, TRUE, 0); test_put_href(doc, FALSE, L"#test", L"http://test.winehq.org/tests/winehq_snapshot/#test", FALSE, TRUE, 0);
test_travellog(doc); test_travellog(doc);
test_refresh(doc); test_refresh(doc);
test_reload(doc);
} }
test_put_href(doc, FALSE, NULL, L"javascript:external%20&&undefined", TRUE, FALSE, 0); test_put_href(doc, FALSE, NULL, L"javascript:external%20&&undefined", TRUE, FALSE, 0);
test_put_href(doc, FALSE, NULL, L"about:blank", FALSE, FALSE, support_wbapp ? DWL_EXPECT_HISTUPDATE : 0); test_put_href(doc, FALSE, NULL, L"about:blank", FALSE, FALSE, support_wbapp ? DWL_EXPECT_HISTUPDATE : 0);
......
/*
* Copyright 2022 Gabriel Ivăncescu for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
var tests = [];
async_test("reload", function() {
if(sessionStorage.getItem("skip reload test")) {
next_test();
return;
}
var script = document.createElement("script");
script.src ="http://winetest.different.org/jsstream.php?reload";
document.getElementsByTagName("head")[0].appendChild(script);
external.writeStream("reload",
' try {' +
' window.location.reload();' +
' sessionStorage.setItem("skip reload test", true);' +
' }catch(e) {' +
' ok(false, "reload with different origin threw " + e.number);' +
' }' +
' next_test()'
);
});
...@@ -64,6 +64,9 @@ events.js HTML "events.js" ...@@ -64,6 +64,9 @@ events.js HTML "events.js"
/* @makedep: documentmode.js */ /* @makedep: documentmode.js */
documentmode.js HTML "documentmode.js" documentmode.js HTML "documentmode.js"
/* @makedep: reload.js */
reload.js HTML "reload.js"
/* @makedep: blank.html */ /* @makedep: blank.html */
blank.html HTML "blank.html" blank.html HTML "blank.html"
......
...@@ -4088,6 +4088,7 @@ static void run_js_tests(void) ...@@ -4088,6 +4088,7 @@ static void run_js_tests(void)
run_script_as_http_with_mode("documentmode.js", "11", "edge;123"); run_script_as_http_with_mode("documentmode.js", "11", "edge;123");
run_script_as_http_with_mode("asyncscriptload.js", NULL, "9"); run_script_as_http_with_mode("asyncscriptload.js", NULL, "9");
run_script_as_http_with_mode("reload.js", NULL, "11");
} }
static BOOL init_registry(BOOL init) static BOOL init_registry(BOOL init)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment