Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
June 2022
- 68 participants
- 3274 messages
Re: [PATCH 0/1] MR126: Draft: ddraw: Limit max texture size to fit a 16bit signed integer
by Stefan Dösinger
Even if we can't test it on the testbot we can test the behavior on real windows machines with a test.
The other interesting thing would be if native ddraw limits the size of sysmem surfaces and/or textures. I vaguely remember that topic coming up in the past too, although I think it was about applications trying to create sysmem surfaces that would occupy more than 4GB of address space.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/126#note_1520
June 2, 2022
Re: [PATCH 0/1] MR126: Draft: ddraw: Limit max texture size to fit a 16bit signed integer
by Henri Verbeet
On Thu, 2 Jun 2022 at 17:39, Fabian Maurer (@DarkShadow44)
<wine(a)gitlab.winehq.org> wrote:
> On Thu Jun 2 13:17:37 2022 +0000, **** wrote:
> > Henri Verbeet replied on the mailing list:
> > ```
> > On Wed, 25 May 2022 at 02:02, Fabian Maurer <wine(a)gitlab.winehq.org> wrote:
> > > Since ddraw propably never allowed sizes that big anyways,
> > > this should not cause any issues.
> > This seems like something it would be easy to write tests for.
> > ```
> Those tests would only work if your GPU advertises 32768x32768 textures though. Would the testbot be able to handle that?
I suspect not, even feature level 12_1 only requires 16384 as maximum
texture dimensions. But a test testing that ddraw never advertises
dwMaxTextureWidth/dwMaxTextureHeight larger than 16384 would still
pass there. You'd need such a GPU to verify the change is in fact
correct, but presumably you already did that.
June 2, 2022
Re: [PATCH v3 6/6] jscript: Don't allow construction on builtin methods.
by Marvin
Hi,
While running your changed tests, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at:
https://testbot.winehq.org/JobDetails.pl?Key=116074
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w7u_adm (32 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w7u_el (32 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w8 (32 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w8adm (32 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w864 (32 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w1064v1507 (32 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w1064v1809 (32 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w1064 (32 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w1064_tsign (32 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w10pro64 (32 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w864 (64 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w1064v1507 (64 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w1064v1809 (64 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w1064 (64 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w1064_2qxl (64 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w1064_adm (64 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w1064_tsign (64 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w10pro64 (64 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w10pro64_en_AE_u8 (64 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w10pro64_ar (64 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w10pro64_ja (64 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
=== w10pro64_zh_CN (64 bit report) ===
jscript:
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
run.c:1094: Test failed: api.js: L"Exception test, num = -2146827843 (a01bd), expected -2146827850. Executed function: function() {new Math.max(5);}"
June 2, 2022
Re: [PATCH 0/1] MR126: Draft: ddraw: Limit max texture size to fit a 16bit signed integer
by Fabian Maurer (@DarkShadow44)
On Thu Jun 2 13:17:37 2022 +0000, **** wrote:
> Henri Verbeet replied on the mailing list:
> ```
> On Wed, 25 May 2022 at 02:02, Fabian Maurer <wine(a)gitlab.winehq.org> wrote:
> > Since ddraw propably never allowed sizes that big anyways,
> > this should not cause any issues.
> This seems like something it would be easy to write tests for.
> ```
Those tests would only work if your GPU advertises 32768x32768 textures though. Would the testbot be able to handle that?
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/126#note_1518
June 2, 2022
[PATCH v3 6/6] jscript: Don't allow construction on builtin methods.
by Gabriel Ivăncescu
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
dlls/jscript/function.c | 2 ++
dlls/jscript/tests/api.js | 1 +
2 files changed, 3 insertions(+)
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c
index 984eebf..37776e6 100644
--- a/dlls/jscript/function.c
+++ b/dlls/jscript/function.c
@@ -619,6 +619,8 @@ static HRESULT NativeFunction_call(script_ctx_t *ctx, FunctionInstance *func, js
{
NativeFunction *function = (NativeFunction*)func;
+ if((flags & DISPATCH_CONSTRUCT) && !(function->function.flags & PROPF_CONSTR))
+ return JS_E_INVALID_PROPERTY;
return function->proc(ctx, vthis, flags & ~DISPATCH_JSCRIPT_INTERNAL_MASK, argc, argv, r);
}
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 1368f39..f103c91 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -2622,6 +2622,7 @@ testException(function() {"test" in nullDisp;}, "E_OBJECT_EXPECTED");
testException(function() {new 3;}, "E_UNSUPPORTED_ACTION");
testException(function() {new null;}, "E_OBJECT_EXPECTED");
testException(function() {new nullDisp;}, "E_NO_PROPERTY");
+testException(function() {new Math.max(5);}, "E_NO_PROPERTY");
testException(function() {new VBArray();}, "E_NOT_VBARRAY");
testException(function() {new VBArray(new VBArray(createArray()));}, "E_NOT_VBARRAY");
testException(function() {VBArray.prototype.lbound.call(new Object());}, "E_NOT_VBARRAY");
--
2.34.1
June 2, 2022
[PATCH v3 5/6] jscript: Release all globals when the script is uninitialized.
by Gabriel Ivăncescu
Most of these globals were leaking before as they were never freed at all.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
dlls/jscript/jscript.c | 31 ++++++++++---------------
dlls/jscript/jscript.h | 50 ++++++++++++++++++++++------------------
dlls/jscript/tests/run.c | 1 -
3 files changed, 40 insertions(+), 42 deletions(-)
diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c
index d6028e6..8a54f32 100644
--- a/dlls/jscript/jscript.c
+++ b/dlls/jscript/jscript.c
@@ -91,6 +91,17 @@ void script_release(script_ctx_t *ctx)
heap_free(ctx);
}
+static void script_globals_release(script_ctx_t *ctx)
+{
+ unsigned i;
+ for(i = 0; i < ARRAY_SIZE(ctx->global_objects); i++) {
+ if(ctx->global_objects[i]) {
+ jsdisp_release(ctx->global_objects[i]);
+ ctx->global_objects[i] = NULL;
+ }
+ }
+}
+
static void change_state(JScript *This, SCRIPTSTATE state)
{
if(This->ctx->state == state)
@@ -483,25 +494,7 @@ static void decrease_state(JScript *This, SCRIPTSTATE state)
This->ctx->site = NULL;
}
- if(This->ctx->map_prototype) {
- jsdisp_release(This->ctx->map_prototype);
- This->ctx->map_prototype = NULL;
- }
-
- if(This->ctx->set_prototype) {
- jsdisp_release(This->ctx->set_prototype);
- This->ctx->set_prototype = NULL;
- }
-
- if(This->ctx->object_prototype) {
- jsdisp_release(This->ctx->object_prototype);
- This->ctx->object_prototype = NULL;
- }
-
- if(This->ctx->global) {
- jsdisp_release(This->ctx->global);
- This->ctx->global = NULL;
- }
+ script_globals_release(This->ctx);
/* FALLTHROUGH */
case SCRIPTSTATE_UNINITIALIZED:
change_state(This, state);
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h
index 000bcc2..0f8baea 100644
--- a/dlls/jscript/jscript.h
+++ b/dlls/jscript/jscript.h
@@ -387,29 +387,35 @@ struct _script_ctx_t {
DWORD last_match_index;
DWORD last_match_length;
- jsdisp_t *global;
- jsdisp_t *function_constr;
- jsdisp_t *array_constr;
- jsdisp_t *bool_constr;
- jsdisp_t *date_constr;
- jsdisp_t *enumerator_constr;
- jsdisp_t *error_constr;
- jsdisp_t *eval_error_constr;
- jsdisp_t *range_error_constr;
- jsdisp_t *reference_error_constr;
- jsdisp_t *regexp_error_constr;
- jsdisp_t *syntax_error_constr;
- jsdisp_t *type_error_constr;
- jsdisp_t *uri_error_constr;
- jsdisp_t *number_constr;
- jsdisp_t *object_constr;
- jsdisp_t *object_prototype;
- jsdisp_t *regexp_constr;
- jsdisp_t *string_constr;
- jsdisp_t *vbarray_constr;
- jsdisp_t *map_prototype;
- jsdisp_t *set_prototype;
+ union {
+ struct {
+ jsdisp_t *global;
+ jsdisp_t *function_constr;
+ jsdisp_t *array_constr;
+ jsdisp_t *bool_constr;
+ jsdisp_t *date_constr;
+ jsdisp_t *enumerator_constr;
+ jsdisp_t *error_constr;
+ jsdisp_t *eval_error_constr;
+ jsdisp_t *range_error_constr;
+ jsdisp_t *reference_error_constr;
+ jsdisp_t *regexp_error_constr;
+ jsdisp_t *syntax_error_constr;
+ jsdisp_t *type_error_constr;
+ jsdisp_t *uri_error_constr;
+ jsdisp_t *number_constr;
+ jsdisp_t *object_constr;
+ jsdisp_t *object_prototype;
+ jsdisp_t *regexp_constr;
+ jsdisp_t *string_constr;
+ jsdisp_t *vbarray_constr;
+ jsdisp_t *map_prototype;
+ jsdisp_t *set_prototype;
+ };
+ jsdisp_t *global_objects[22];
+ };
};
+C_ASSERT(RTL_SIZEOF_THROUGH_FIELD(script_ctx_t, set_prototype) == RTL_SIZEOF_THROUGH_FIELD(script_ctx_t, global_objects));
void script_release(script_ctx_t*) DECLSPEC_HIDDEN;
diff --git a/dlls/jscript/tests/run.c b/dlls/jscript/tests/run.c
index f7ad1fe..ec054f0 100644
--- a/dlls/jscript/tests/run.c
+++ b/dlls/jscript/tests/run.c
@@ -3293,7 +3293,6 @@ static void test_invokeex(void)
str = SysAllocString(L"call");
hres = IDispatchEx_GetDispID(dispex, str, 0, &func_id);
SysFreeString(str);
- todo_wine
ok(hres == E_UNEXPECTED, "GetDispID failed: %08lx\n", hres);
IDispatchEx_Release(dispex);
--
2.34.1
June 2, 2022
[PATCH v3 4/6] jscript: Forward actual error in to_primitive if it's not just missing prop.
by Gabriel Ivăncescu
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
Needed for next patch.
dlls/jscript/jsutils.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/dlls/jscript/jsutils.c b/dlls/jscript/jsutils.c
index 3251abf..96e4262 100644
--- a/dlls/jscript/jsutils.c
+++ b/dlls/jscript/jsutils.c
@@ -422,6 +422,9 @@ HRESULT to_primitive(script_ctx_t *ctx, jsval_t val, jsval_t *ret, hint_t hint)
}else {
IDispatch_Release(get_object(prim));
}
+ }else if(hres != DISP_E_UNKNOWNNAME) {
+ jsdisp_release(jsdisp);
+ return hres;
}
hres = jsdisp_get_id(jsdisp, hint == HINT_STRING ? L"valueOf" : L"toString", 0, &id);
@@ -438,6 +441,9 @@ HRESULT to_primitive(script_ctx_t *ctx, jsval_t val, jsval_t *ret, hint_t hint)
}else {
IDispatch_Release(get_object(prim));
}
+ }else if(hres != DISP_E_UNKNOWNNAME) {
+ jsdisp_release(jsdisp);
+ return hres;
}
jsdisp_release(jsdisp);
--
2.34.1
June 2, 2022
[PATCH v3 3/6] jscript: Don't execute any functions if script state does not allow it.
by Gabriel Ivăncescu
Instead of only interpreted functions. Property retrievals or setters are
allowed though, as long as they are not accessors.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
dlls/jscript/dispex.c | 3 ++
dlls/jscript/function.c | 10 ++--
dlls/jscript/tests/run.c | 111 ++++++++++++++++++++++++++++++++++++---
3 files changed, 111 insertions(+), 13 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index df829b7..298f7e1 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -1971,6 +1971,9 @@ HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsig
return JS_E_FUNCTION_EXPECTED;
}
+ if(jsfunc->ctx->state == SCRIPTSTATE_UNINITIALIZED || jsfunc->ctx->state == SCRIPTSTATE_CLOSED)
+ return E_UNEXPECTED;
+
flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK;
hres = jsfunc->builtin_info->call(jsfunc->ctx, jsthis ? jsval_disp(jsthis) : jsval_null(), flags, argc, argv, r);
}
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c
index 18465e5..984eebf 100644
--- a/dlls/jscript/function.c
+++ b/dlls/jscript/function.c
@@ -257,6 +257,11 @@ HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsi
assert(is_class(func_this, JSCLASS_FUNCTION));
function = function_from_jsdisp(func_this);
+ if(function->dispex.ctx->state == SCRIPTSTATE_UNINITIALIZED || function->dispex.ctx->state == SCRIPTSTATE_CLOSED) {
+ WARN("Script engine state does not allow running code.\n");
+ return E_UNEXPECTED;
+ }
+
if(jsthis)
vthis = jsval_disp(jsthis);
else
@@ -725,11 +730,6 @@ static HRESULT InterpretedFunction_call(script_ctx_t *ctx, FunctionInstance *fun
TRACE("%p\n", function);
- if(ctx->state == SCRIPTSTATE_UNINITIALIZED || ctx->state == SCRIPTSTATE_CLOSED) {
- WARN("Script engine state does not allow running code.\n");
- return E_UNEXPECTED;
- }
-
if(flags & DISPATCH_CONSTRUCT) {
hres = create_object(ctx, &function->function.dispex, &new_obj);
if(FAILED(hres))
diff --git a/dlls/jscript/tests/run.c b/dlls/jscript/tests/run.c
index 94dc2e1..f7ad1fe 100644
--- a/dlls/jscript/tests/run.c
+++ b/dlls/jscript/tests/run.c
@@ -2914,13 +2914,20 @@ static void test_default_value(void)
V_VT(&v) = VT_EMPTY;
hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
- ok(hres == S_OK || broken(hres == 0x8000ffff), "Invoke failed: %08lx\n", hres);
- if(hres == S_OK)
- {
- ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
- }
+ ok(hres == E_UNEXPECTED, "Invoke failed: %08lx\n", hres);
+
+ hres = parse_script_expr(L"new Date()", &v, &script);
+ ok(hres == S_OK, "parse_script_expr failed: %08lx\n", hres);
+ ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
+ disp = V_DISPATCH(&v);
+
+ V_VT(&v) = VT_EMPTY;
+ hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
+ ok(hres == S_OK, "Invoke failed: %08lx\n", hres);
+ ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
VariantClear(&v);
IDispatch_Release(disp);
+ close_script(script);
hres = parse_script_expr(L"var arr = [5]; arr.toString = function() {return \"foo\";}; arr.valueOf = function() {return 42;}; arr", &v, &script);
ok(hres == S_OK, "parse_script_expr failed: %08lx\n", hres);
@@ -3149,15 +3156,15 @@ static void test_script_exprs(void)
static void test_invokeex(void)
{
- DISPID func_id, prop_id;
- DISPPARAMS dp = {NULL};
+ DISPPARAMS dp = {NULL}, dp_max = {NULL};
+ DISPID func_id, max_id, prop_id;
IActiveScript *script;
IDispatchEx *dispex;
VARIANT v, arg;
BSTR str;
HRESULT hres;
- hres = parse_script_expr(L"var o = {func: function() {return 3;}, prop: 6}; o", &v, &script);
+ hres = parse_script_expr(L"var o = {func: function() {return 3;}, max: Math.max, prop: 6}; o", &v, &script);
ok(hres == S_OK, "parse_script_expr failed: %08lx\n", hres);
ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
@@ -3170,16 +3177,31 @@ static void test_invokeex(void)
SysFreeString(str);
ok(hres == S_OK, "GetDispID failed: %08lx\n", hres);
+ str = SysAllocString(L"max");
+ hres = IDispatchEx_GetDispID(dispex, str, 0, &max_id);
+ SysFreeString(str);
+ ok(hres == S_OK, "GetDispID failed: %08lx\n", hres);
+
str = SysAllocString(L"prop");
hres = IDispatchEx_GetDispID(dispex, str, 0, &prop_id);
SysFreeString(str);
ok(hres == S_OK, "GetDispID failed: %08lx\n", hres);
+ dp_max.rgvarg = &arg;
+ dp_max.cArgs = 1;
+ V_VT(&arg) = VT_I4;
+ V_I4(&arg) = 42;
+
hres = IDispatchEx_InvokeEx(dispex, func_id, 0, DISPATCH_METHOD, &dp, &v, NULL, NULL);
ok(hres == S_OK, "InvokeEx failed: %08lx\n", hres);
ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
ok(V_I4(&v) == 3, "V_I4(v) = %ld\n", V_I4(&v));
+ hres = IDispatchEx_InvokeEx(dispex, max_id, 0, DISPATCH_METHOD, &dp_max, &v, NULL, NULL);
+ ok(hres == S_OK, "InvokeEx failed: %08lx\n", hres);
+ ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
+ ok(V_I4(&v) == 42, "V_I4(v) = %ld\n", V_I4(&v));
+
hres = IDispatchEx_InvokeEx(dispex, prop_id, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
ok(hres == S_OK, "InvokeEx failed: %08lx\n", hres);
ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
@@ -3193,9 +3215,23 @@ static void test_invokeex(void)
SysFreeString(str);
ok(hres == S_OK, "GetDispID failed: %08lx\n", hres);
+ V_VT(&v) = VT_EMPTY;
hres = IDispatchEx_InvokeEx(dispex, func_id, 0, DISPATCH_METHOD, &dp, &v, NULL, NULL);
ok(hres == E_UNEXPECTED || broken(hres == 0x800a1393), "InvokeEx failed: %08lx\n", hres);
+ V_VT(&v) = VT_EMPTY;
+ hres = IDispatchEx_InvokeEx(dispex, max_id, 0, DISPATCH_METHOD, &dp_max, &v, NULL, NULL);
+ ok(hres == E_UNEXPECTED || broken(hres == 0x800a1393), "InvokeEx failed: %08lx\n", hres);
+
+ V_VT(&v) = VT_EMPTY;
+ hres = IDispatchEx_InvokeEx(dispex, prop_id, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
+ ok(hres == S_OK, "InvokeEx failed: %08lx\n", hres);
+ ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
+ ok(V_I4(&v) == 6, "V_I4(v) = %ld\n", V_I4(&v));
+
+ IActiveScript_Close(script);
+
+ V_VT(&v) = VT_EMPTY;
hres = IDispatchEx_InvokeEx(dispex, prop_id, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
ok(hres == S_OK, "InvokeEx failed: %08lx\n", hres);
ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
@@ -3204,6 +3240,65 @@ static void test_invokeex(void)
IDispatchEx_Release(dispex);
IActiveScript_Release(script);
+ hres = parse_script_expr(L"Math.max", &v, &script);
+ ok(hres == S_OK, "parse_script_expr failed: %08lx\n", hres);
+ ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
+
+ hres = IDispatch_QueryInterface(V_DISPATCH(&v), &IID_IDispatchEx, (void**)&dispex);
+ ok(hres == S_OK, "Could not get IDispatchEx iface: %08lx\n", hres);
+ VariantClear(&v);
+
+ str = SysAllocString(L"call");
+ hres = IDispatchEx_GetDispID(dispex, str, 0, &func_id);
+ SysFreeString(str);
+ ok(hres == S_OK, "GetDispID failed: %08lx\n", hres);
+
+ hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
+ ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08lx\n", hres);
+
+ str = SysAllocString(L"call");
+ hres = IDispatchEx_GetDispID(dispex, str, 0, &func_id);
+ SysFreeString(str);
+ ok(hres == S_OK, "GetDispID failed: %08lx\n", hres);
+
+ str = SysAllocString(L"length");
+ hres = IDispatchEx_GetDispID(dispex, str, 0, &prop_id);
+ SysFreeString(str);
+ ok(hres == S_OK, "GetDispID failed: %08lx\n", hres);
+
+ hres = IDispatchEx_InvokeEx(dispex, func_id, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
+ ok(hres == S_OK, "InvokeEx failed: %08lx\n", hres);
+ ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
+ VariantClear(&v);
+
+ hres = IDispatchEx_InvokeEx(dispex, prop_id, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
+ ok(hres == S_OK, "InvokeEx failed: %08lx\n", hres);
+ ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
+ ok(V_I4(&v) == 2, "V_I4(v) = %ld\n", V_I4(&v));
+
+ IDispatchEx_Release(dispex);
+ IActiveScript_Release(script);
+
+ hres = parse_script_expr(L"Math.max", &v, &script);
+ ok(hres == S_OK, "parse_script_expr failed: %08lx\n", hres);
+ ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
+
+ hres = IDispatch_QueryInterface(V_DISPATCH(&v), &IID_IDispatchEx, (void**)&dispex);
+ ok(hres == S_OK, "Could not get IDispatchEx iface: %08lx\n", hres);
+ VariantClear(&v);
+
+ hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
+ ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08lx\n", hres);
+
+ str = SysAllocString(L"call");
+ hres = IDispatchEx_GetDispID(dispex, str, 0, &func_id);
+ SysFreeString(str);
+ todo_wine
+ ok(hres == E_UNEXPECTED, "GetDispID failed: %08lx\n", hres);
+
+ IDispatchEx_Release(dispex);
+ IActiveScript_Release(script);
+
/* test InvokeEx following prototype chain of builtin object (PROP_PROTREF) */
hres = parse_script_expr(L"o = new Array(); o.push(\"foo\"); o", &v, &script);
ok(hres == S_OK, "parse_script_expr failed: %08lx\n", hres);
--
2.34.1
June 2, 2022
[PATCH v3 2/6] jscript: Setup builtin function when the dispid is retrieved.
by Gabriel Ivăncescu
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
dlls/jscript/dispex.c | 67 ++++++++++++++---------------------------
dlls/jscript/function.c | 3 ++
2 files changed, 25 insertions(+), 45 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index 468a0dd..df829b7 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -242,6 +242,7 @@ static HRESULT find_prop_name(jsdisp_t *This, unsigned hash, const WCHAR *name,
const builtin_prop_t *builtin;
unsigned bucket, pos, prev = ~0;
dispex_prop_t *prop;
+ HRESULT hres;
bucket = get_props_idx(This, hash);
pos = This->props[bucket].bucket_head;
@@ -264,9 +265,24 @@ static HRESULT find_prop_name(jsdisp_t *This, unsigned hash, const WCHAR *name,
builtin = find_builtin_prop(This, name);
if(builtin) {
unsigned flags = builtin->flags;
- if(flags & PROPF_METHOD)
- flags |= PROPF_WRITABLE | PROPF_CONFIGURABLE;
- else if(builtin->setter)
+ if(flags & PROPF_METHOD) {
+ jsdisp_t *obj;
+
+ hres = create_builtin_function(This->ctx, builtin->invoke, builtin->name, NULL, flags, NULL, &obj);
+ if(FAILED(hres))
+ return hres;
+
+ prop = alloc_prop(This, name, PROP_JSVAL, (flags & PROPF_ALL) | PROPF_WRITABLE | PROPF_CONFIGURABLE);
+ if(!prop) {
+ jsdisp_release(obj);
+ return E_OUTOFMEMORY;
+ }
+
+ prop->type = PROP_JSVAL;
+ prop->u.val = jsval_obj(obj);
+ *ret = prop;
+ return S_OK;
+ }else if(builtin->setter)
flags |= PROPF_WRITABLE;
flags &= PROPF_ENUMERABLE | PROPF_WRITABLE | PROPF_CONFIGURABLE;
prop = alloc_prop(This, name, PROP_BUILTIN, flags);
@@ -431,23 +447,7 @@ static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, jsval_t *r)
switch(prop->type) {
case PROP_BUILTIN:
- if(prop->u.p->getter) {
- hres = prop->u.p->getter(This->ctx, This, r);
- }else {
- jsdisp_t *obj;
-
- assert(prop->u.p->invoke != NULL);
- hres = create_builtin_function(This->ctx, prop->u.p->invoke, prop->u.p->name, NULL,
- prop->u.p->flags, NULL, &obj);
- if(FAILED(hres))
- break;
-
- prop->type = PROP_JSVAL;
- prop->u.val = jsval_obj(obj);
-
- jsdisp_addref(obj);
- *r = jsval_obj(obj);
- }
+ hres = prop->u.p->getter(This->ctx, This, r);
break;
case PROP_JSVAL:
hres = jsval_copy(prop->u.val, r);
@@ -497,12 +497,6 @@ static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, jsval_t val)
switch(prop->type) {
case PROP_BUILTIN:
- if(prop->u.p->invoke) {
- prop->type = PROP_JSVAL;
- prop->flags = PROPF_CONFIGURABLE | PROPF_WRITABLE;
- prop->u.val = jsval_undefined();
- break;
- }
if(!prop->u.p->setter) {
TRACE("getter with no setter\n");
return S_OK;
@@ -557,25 +551,8 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t
HRESULT hres;
switch(prop->type) {
- case PROP_BUILTIN: {
- jsval_t vthis;
-
- if(!prop->u.p->invoke)
- return JS_E_FUNCTION_EXPECTED;
-
- if(flags == DISPATCH_CONSTRUCT && (prop->flags & PROPF_METHOD)) {
- WARN("%s is not a constructor\n", debugstr_w(prop->name));
- return E_INVALIDARG;
- }
-
- if(This->builtin_info->class != JSCLASS_FUNCTION && prop->u.p->invoke != JSGlobal_eval)
- flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK;
- if(jsthis)
- vthis = jsval_disp(jsthis);
- else
- vthis = jsval_obj(This);
- return prop->u.p->invoke(This->ctx, vthis, flags, argc, argv, r);
- }
+ case PROP_BUILTIN:
+ return JS_E_FUNCTION_EXPECTED;
case PROP_PROTREF:
return invoke_prop_func(This->prototype, jsthis ? jsthis : (IDispatch *)&This->IDispatchEx_iface,
This->prototype->props+prop->u.ref, flags, argc, argv, r, caller);
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c
index 638d176..18465e5 100644
--- a/dlls/jscript/function.c
+++ b/dlls/jscript/function.c
@@ -664,6 +664,9 @@ HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc,
NativeFunction *function;
HRESULT hres;
+ if(!ctx->function_constr)
+ return E_UNEXPECTED;
+
hres = create_function(ctx, builtin_info, &NativeFunctionVtbl, sizeof(NativeFunction), flags, FALSE, NULL, (void**)&function);
if(FAILED(hres))
return hres;
--
2.34.1
June 2, 2022
[PATCH v3 1/6] jscript: Don't allow starting script using state from uninitialized.
by Gabriel Ivăncescu
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
dlls/jscript/jscript.c | 2 +-
dlls/jscript/tests/jscript.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c
index 8cf141d..d6028e6 100644
--- a/dlls/jscript/jscript.c
+++ b/dlls/jscript/jscript.c
@@ -824,7 +824,7 @@ static HRESULT WINAPI JScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE s
switch(ss) {
case SCRIPTSTATE_STARTED:
case SCRIPTSTATE_CONNECTED: /* FIXME */
- if(This->ctx->state == SCRIPTSTATE_CLOSED)
+ if(This->ctx->state == SCRIPTSTATE_UNINITIALIZED || This->ctx->state == SCRIPTSTATE_CLOSED)
return E_UNEXPECTED;
exec_queued_code(This);
diff --git a/dlls/jscript/tests/jscript.c b/dlls/jscript/tests/jscript.c
index 8c985e5..8723541 100644
--- a/dlls/jscript/tests/jscript.c
+++ b/dlls/jscript/tests/jscript.c
@@ -863,6 +863,12 @@ static void test_jscript_uninitializing(void)
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08lx\n", hres);
+ hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED);
+ ok(hres == E_UNEXPECTED, "SetScriptState(SCRIPTSTATE_STARTED) returned: %08lx\n", hres);
+
+ hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
+ ok(hres == E_UNEXPECTED, "SetScriptState(SCRIPTSTATE_CONNECTED) returned: %08lx\n", hres);
+
SET_EXPECT(GetLCID);
SET_EXPECT(OnStateChange_INITIALIZED);
hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
--
2.34.1
June 2, 2022