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.