# [webkit-qt] jsMath behavior different on win vs. linux

Carter, Nathan NCARTER at bentley.edu
Mon Apr 12 08:26:16 PDT 2010

Hello again.

Following up on last night's exchange, I'm having trouble even getting a simple webkit instance to run jsMath.  I'm not sure why this is the case, because

1) I have it working in a more complex arrangement in my actual application (which makes several different timed calls to JavaScript routines in the webview), and

2) the same HTML I use here works fine in Safari, for example.  However, it does not work in Chrome.  It's very basic, and follows the jsMath documentation.

Source code (single main.cpp file) appears at the end of this message.  To build, run qmake -project, edit project to add CONFIG += console if you want (and CONFIG -= app_bundle on Mac), qmake, make.

Other difficulties include that different versions of jsMath yield different results on this same HTML content:
3.6c	works	fails*	works
3.6d	works	fails*	fails*
3.6e	fails*	fails*	fails*
*fails == does not process the mathematics.  In each browser, the error is different, but since this is not a jsMath email list, I'll spare you the details.

Any idea what's going wrong here, or with these inconsistencies?  Specifically, why doesn't jsMath even load?  I've tried adding these lines, to make it easier to tinker with what's going wrong in the web view's JavaScript environment, but it brings up a completely blank, gray window (no inspector to be seen).
QWebInspector wi;
wi.setPage( wv.page() );
wi.show();
wi.raise();

Nathan

#include <QApplication>
#include <QWebView>
#include <QWebFrame>
#include <QDebug>

#define HTML_CONTENT "<HTML>\n" \
"    <BODY>\n" \
"        <DIV class='math'>\n" \
"            \\int_0^1 xe^x\\;dx\n" \
"        </DIV>\n" \
"    </BODY>\n" \
"</HTML>\n"

int main ( int argc, char** argv )
{
QApplication app(argc,argv);
QWebView wv;
QString html = QString( HTML_CONTENT ).arg( JSMATH_PATH );
qDebug() << html; // prints expected content
wv.setHtml( html );
wv.show();
wv.raise();
app.exec();
qDebug() << wv.page()->mainFrame()->evaluateJavaScript( "jsMath" ).toString();
// prints empty string, as if jsMath still undefined
// note that this is after a pause, when quitting the app
// so there has been plenty of time for jsMath to load!
}