Permalink
Browse files

now we eval each JS files separately so that the line numbers in the …

…parse error messages should always make sense

git-svn-id: http://svn1.bj.corp.yahoo.com/repos/WebEng/lifesearch/vdom-webkit/VdomBrowser@61786 82b2e94c-9313-0410-8ced-81db5252d7f6
  • Loading branch information...
1 parent 0badd4d commit d0679af6554e6f604b75ef95c0501722bb59054d agentzh committed Jul 30, 2009
Showing with 26 additions and 26 deletions.
  1. +25 −25 mainwindow.cpp
  2. +1 −1 mainwindow.h
View
50 mainwindow.cpp
@@ -87,9 +87,30 @@ void MainWindow::loadFinished(bool done) {
m_urlEdit->setText(m_view->url().toEncoded());
addUrlToList();
- if (!m_injectedJS.isNull() && m_injectedJS != "") {
- QVariant res = evalJS(m_injectedJS + "true");
- qDebug() << "injecting JS res: " << res << endl;
+ if (!m_injectedJSFiles.isEmpty()) {
+ for (int i = 0; i < m_injectedJSFiles.count(); i++) {
+ const QString& fileName = m_injectedJSFiles[i];
+ //qDebug() << QString("Checking if file %1 is readable...")
+ //.arg(fileName).toUtf8() << endl;
+ if (!QFile::exists(fileName)) {
+ qDebug() <<
+ QString("js file \"%1\" not found.\n").arg(fileName).toUtf8().data();
+ continue;
+ }
+
+ QFile file(fileName);
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ qDebug() <<
+ QString("Failed to load js file %1: %2\n")
+ .arg(fileName).arg(file.errorString()).toUtf8();
+ file.close();
+ continue;
+ }
+ qDebug() << "Loading JS file " << fileName << "...\n";
+ QString injectedJS = QString::fromUtf8(file.readAll()) + "\n";
+ QVariant res = evalJS(injectedJS + "true");
+ qDebug() << "injecting JS res: " << res << endl;
+ }
}
if (m_hunterEnabled) {
@@ -1000,28 +1021,7 @@ void MainWindow::loadUrl(const QUrl& url) {
}
void MainWindow::setJSFiles(QStringList& jsFiles) {
- m_injectedJS.clear();
- for (int i = 0; i < jsFiles.count(); i++) {
- const QString& fileName = jsFiles[i];
- //qDebug() << QString("Checking if file %1 is readable...")
- //.arg(fileName).toUtf8() << endl;
- if (!QFile::exists(fileName)) {
- qDebug() <<
- QString("js file \"%1\" not found.\n").arg(fileName).toUtf8().data();
- continue;
- }
-
- QFile file(fileName);
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- qDebug() <<
- QString("Failed to load js file %1: %2\n")
- .arg(fileName).arg(file.errorString()).toUtf8();
- file.close();
- continue;
- }
- //qDebug() << "Reading file " << fileName << endl;
- m_injectedJS += QString::fromUtf8(file.readAll()) + "\n";
- }
+ m_injectedJSFiles = jsFiles;
//qDebug() << "!!! JS: " << m_injectedJS << endl;
}
View
2 mainwindow.h
@@ -269,7 +269,7 @@ protected slots:
Iterator m_iterator;
QSplitter* m_mainSplitter;
- QString m_injectedJS;
+ QStringList m_injectedJSFiles;
};
#endif

0 comments on commit d0679af

Please sign in to comment.