https://bugs.winehq.org/show_bug.cgi?id=51241
Bug ID: 51241 Summary: VBScript code to detect a VBScript capable browser doesn't work in Wine's mshtml/vbscript Product: Wine Version: 6.10 Hardware: x86-64 OS: Linux Status: NEW Severity: normal Priority: P2 Component: mshtml Assignee: wine-bugs@winehq.org Reporter: dmitry@baikal.ru CC: jacek@codeweavers.com Distribution: ---
I'm not sure how to separate this problem between mshtml/vbscript since one part depends on another one.
I have a Web application that uses the technique to detect a VBScript capable browser described in https://stackoverflow.com/questions/22750096/detect-if-browser-is-vbscript-c...
The JScript code embedded in an HTML page looks like this:
var supportsVb = (function() { var supports = false; var vb = document.createElement('script'); vb.type="text/vbscript"; try { vb.innerText="Err.Raise"; } catch (e) { supports = true; } return supports })()
The problem is that this doesn't generate an exception and as a result variable 'supports' contains 'false'.
First part of the problem is that 'vb.innerText="Err.Raise";' doesn't set the text for HTMLScriptElement and as a result the VBScript code "Err.Raise" is not executed. I've fixed this in IHTMLElement_put_innerText() by checking the HTMLElement tag, and if it's "SCRIPT" forward the call to IHTMLScriptElement_put_text().
After that IHTMLScriptElement_put_text() refuses to execute the script because it doesn't have a parent node. I've fixed this by removing the check for parent node in IHTMLScriptElement_put_text().
After that VBScript engine gets actually called to interpret "Err.Raise", however it doesn't generate an exception. Note, that "Err.Raise" doesn't have the arguments, and according to the tests that's correct behaviour, and this leads to VBSE_FUNC_ARITY_MISMATCH (450) being returned by Raise(), however even if passed any error code as an argument Raise() doesn't generate an exception that could be catched by the JScript code.
I'll attach appropriate log snippets and my hacks/fixes.
https://bugs.winehq.org/show_bug.cgi?id=51241
--- Comment #1 from Dmitry Timoshkov dmitry@baikal.ru --- Created attachment 70114 --> https://bugs.winehq.org/attachment.cgi?id=70114 +seh,+tid,+wininet,+urlmon,+mshtml,+vbscript,+jscript log with wine-6.10
https://bugs.winehq.org/show_bug.cgi?id=51241
--- Comment #2 from Dmitry Timoshkov dmitry@baikal.ru --- Created attachment 70115 --> https://bugs.winehq.org/attachment.cgi?id=70115 Patch for IHTMLElement_put_innerText() that forwards the call to the script element
https://bugs.winehq.org/show_bug.cgi?id=51241
--- Comment #3 from Dmitry Timoshkov dmitry@baikal.ru --- Created attachment 70116 --> https://bugs.winehq.org/attachment.cgi?id=70116 +seh,+tid,+wininet,+urlmon,+mshtml,+vbscript,+jscript log with wine-6.10 + patch for innerText
https://bugs.winehq.org/show_bug.cgi?id=51241
--- Comment #4 from Dmitry Timoshkov dmitry@baikal.ru --- Jacek, could you please have a look at this?
https://bugs.winehq.org/show_bug.cgi?id=51241
--- Comment #5 from Jacek Caban jacek@codeweavers.com --- (In reply to Dmitry Timoshkov from comment #0)
First part of the problem is that 'vb.innerText="Err.Raise";' doesn't set the text for HTMLScriptElement and as a result the VBScript code "Err.Raise" is not executed. I've fixed this in IHTMLElement_put_innerText() by checking the HTMLElement tag, and if it's "SCRIPT" forward the call to IHTMLScriptElement_put_text().
We have NodeImplVtbl for such cases, you could add another entry there.
After that IHTMLScriptElement_put_text() refuses to execute the script because it doesn't have a parent node. I've fixed this by removing the check for parent node in IHTMLScriptElement_put_text().
We have quite a few tests for that. I'd expect your patch to break them (and, in any case, extending tests will give us answer how it's supposed to work).
After that VBScript engine gets actually called to interpret "Err.Raise", however it doesn't generate an exception. Note, that "Err.Raise" doesn't have the arguments, and according to the tests that's correct behaviour, and this leads to VBSE_FUNC_ARITY_MISMATCH (450) being returned by Raise(), however even if passed any error code as an argument Raise() doesn't generate an exception that could be catched by the JScript code.
Looking at the example, it seems like innerText should somehow propagate the exception.