Jacek Caban : mshtml: Use first script host's GUID as default script guid.
Alexandre Julliard
julliard at winehq.org
Mon Sep 10 15:22:11 CDT 2012
Module: wine
Branch: master
Commit: 156e94429d8bbcf73c194e82864cc9ed2bee1771
URL: http://source.winehq.org/git/wine.git/?a=commit;h=156e94429d8bbcf73c194e82864cc9ed2bee1771
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Sep 10 10:34:52 2012 +0200
mshtml: Use first script host's GUID as default script guid.
---
dlls/mshtml/htmlwindow.c | 1 -
dlls/mshtml/mshtml_private.h | 1 -
dlls/mshtml/script.c | 18 ++++++++++--------
dlls/mshtml/tests/vbtest.html | 15 +++++++++++++--
4 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index bdec9b9..ed1fa2b 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -2721,7 +2721,6 @@ static HRESULT create_inner_window(HTMLOuterWindow *outer_window, IMoniker *mon,
init_dispex(&window->dispex, (IUnknown*)&window->base.IHTMLWindow2_iface, &HTMLWindow_dispex);
window->task_magic = get_task_target_magic();
- window->current_script_guid = CLSID_JScript;
if(mon) {
IMoniker_AddRef(mon);
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 18496aa..fa4e073 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -388,7 +388,6 @@ struct HTMLInnerWindow {
HTMLDocumentNode *doc;
struct list script_hosts;
- GUID current_script_guid;
IHTMLEventObj *event;
diff --git a/dlls/mshtml/script.c b/dlls/mshtml/script.c
index 0fe4f5a..9aa875a 100644
--- a/dlls/mshtml/script.c
+++ b/dlls/mshtml/script.c
@@ -641,8 +641,6 @@ static void parse_text(ScriptHost *script_host, LPCWSTR text)
TRACE("%s\n", debugstr_w(text));
- script_host->window->current_script_guid = script_host->guid;
-
VariantInit(&var);
memset(&excepinfo, 0, sizeof(excepinfo));
TRACE(">>>\n");
@@ -722,6 +720,14 @@ static void parse_script_elem(ScriptHost *script_host, nsIDOMHTMLScriptElement *
nsAString_Finish(&src_str);
}
+static GUID get_default_script_guid(HTMLInnerWindow *window)
+{
+ /* If not specified, we should use very first script host that was created for the page (or JScript if none) */
+ return list_empty(&window->script_hosts)
+ ? CLSID_JScript
+ : LIST_ENTRY(list_head(&window->script_hosts), ScriptHost, entry)->guid;
+}
+
static BOOL get_guid_from_type(LPCWSTR type, GUID *guid)
{
const WCHAR text_javascriptW[] =
@@ -790,7 +796,7 @@ static BOOL get_script_guid(HTMLInnerWindow *window, nsIDOMHTMLScriptElement *ns
if(*language) {
ret = get_guid_from_language(language, guid);
}else {
- *guid = window->current_script_guid;
+ *guid = get_default_script_guid(window);
ret = TRUE;
}
}else {
@@ -871,7 +877,7 @@ IDispatch *script_parse_event(HTMLInnerWindow *window, LPCWSTR text)
ptr++;
}else {
ptr = text;
- guid = window->current_script_guid;
+ guid = get_default_script_guid(window);
}
if(IsEqualGUID(&CLSID_JScript, &guid)
@@ -880,8 +886,6 @@ IDispatch *script_parse_event(HTMLInnerWindow *window, LPCWSTR text)
return NULL;
}
- window->current_script_guid = guid;
-
script_host = get_script_host(window, &guid);
if(!script_host || !script_host->parse_proc)
return NULL;
@@ -923,8 +927,6 @@ HRESULT exec_script(HTMLInnerWindow *window, const WCHAR *code, const WCHAR *lan
return E_FAIL;
}
- window->current_script_guid = guid;
-
memset(&ei, 0, sizeof(ei));
TRACE(">>>\n");
hres = IActiveScriptParse_ParseScriptText(script_host->parse, code, NULL, NULL, delimW, 0, 0, SCRIPTTEXT_ISVISIBLE, ret, &ei);
diff --git a/dlls/mshtml/tests/vbtest.html b/dlls/mshtml/tests/vbtest.html
index 7b8cebc..b864abc 100644
--- a/dlls/mshtml/tests/vbtest.html
+++ b/dlls/mshtml/tests/vbtest.html
@@ -12,19 +12,30 @@ End Sub
<script>
' Verifies that we're in VBScript although there is no type specified
If true then counter = counter+1
+function inccounter(x)
+ counter = counter+x
+end function
</script>
<script type="text/javascript">
// We're in javascript
+try {
+ counter++;
+ incCounter(2);
+}catch(e) {
+ ok(false, "got an exception");
+}
</script>
-<script type="text/vbscript">
+<script>
' And back to VBScript
If true then counter = counter+1
Sub runTest()
- Call ok(counter = 3, "counter = " & counter)
+ Call ok(counter = 6, "counter = " & counter)
Call external.reportSuccess()
End Sub
</script>
+<script type="text/javascript">
+// We're in javascript
</script>
<body onload="If true then runTest()">
</body>
More information about the wine-cvs
mailing list