History

block until follow-on includes are finished but still avoid multiple evaluation of included urls

Seth Alves committed 10 years ago

Commit aef39ce1 parent 5b91c8f1 file · +11 −14Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+11−14
@@ -1187,20 +1187,15 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac · 1186 unmodified lines
1187 thisURL = resolvePath(file);1187 thisURL = resolvePath(file);
1188 }1188 }
1189 1189
1190 if (!_includedURLs.contains(thisURL)) {1190 if (!isStandardLibrary && !currentSandboxURL.isEmpty() && (thisURL.scheme() == "file") &&
1191 if (!isStandardLibrary && !currentSandboxURL.isEmpty() && (thisURL.scheme() == "file") &&1191 (currentSandboxURL.scheme() != "file" ||
1192 (currentSandboxURL.scheme() != "file" ||1192 !thisURL.toString(strippingFlags).startsWith(currentSandboxURL.toString(strippingFlags), getSensitivity()))) {
1193 !thisURL.toString(strippingFlags).startsWith(currentSandboxURL.toString(strippingFlags), getSensitivity()))) {1193 qCWarning(scriptengine) << "Script.include() ignoring file path"
1194 qCWarning(scriptengine) << "Script.include() ignoring file path"1194 << thisURL << "outside of original entity script" << currentSandboxURL;
1195 << thisURL << "outside of original entity script" << currentSandboxURL;
1196 } else {
1197 // We could also check here for CORS, but we don't yet.
1198 // It turns out that QUrl.resolve will not change hosts and copy authority, so we don't need to check that here.
1199 urls.append(thisURL);
1200 _includedURLs << thisURL;
1201 }
1202 } else {1195 } else {
1203 qCDebug(scriptengine) << "Script.include() ignoring previously included url:" << thisURL;1196 // We could also check here for CORS, but we don't yet.
1197 // It turns out that QUrl.resolve will not change hosts and copy authority, so we don't need to check that here.
1198 urls.append(thisURL);
1204 }1199 }
1205 }1200 }
1206 1201
@@ -1219,13 +1214,15 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac · 12 unmodified lines
1219 QString contents = data[url];1214 QString contents = data[url];
1220 if (contents.isNull()) {1215 if (contents.isNull()) {
1221 qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__;1216 qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__;
1222 } else {1217 } else if (!_includedURLs.contains(url)) {
1218 _includedURLs << url;
1223 // Set the parent url so that path resolution will be relative1219 // Set the parent url so that path resolution will be relative
1224 // to this script's url during its initial evaluation1220 // to this script's url during its initial evaluation
1225 _parentURL = url.toString();1221 _parentURL = url.toString();
1226 auto operation = [&]() {1222 auto operation = [&]() {
1227 evaluate(contents, url.toString());1223 evaluate(contents, url.toString());
1228 };1224 };
1225
1229 doWithEnvironment(capturedEntityIdentifier, capturedSandboxURL, operation);1226 doWithEnvironment(capturedEntityIdentifier, capturedSandboxURL, operation);
1230 }1227 }
1231 }1228 }