OpenCoverage

qv4include.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4include.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8QV4Include::QV4Include(const QUrl &url, QV4::ExecutionEngine *engine,-
9 QV4::QmlContext *qmlContext, const QV4::Value &callback)-
10 : v4(engine), m_url(url)-
11-
12 , m_redirectCount(0), m_network(nullptr) , m_reply(nullptr)-
13-
14{-
15 if (qmlContext
qmlContextDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
)
0-6
16 m_qmlContext.set(engine, *qmlContext);
executed 6 times by 1 test: m_qmlContext.set(engine, *qmlContext);
Executed by:
  • tst_qqmlecmascript
6
17 if (callback.as<QV4::FunctionObject>()
callback.as<QV...ctionObject>()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
)
0-6
18 m_callbackFunction.set(engine, callback);
executed 6 times by 1 test: m_callbackFunction.set(engine, callback);
Executed by:
  • tst_qqmlecmascript
6
19-
20 m_resultObject.set(v4, resultValue(v4));-
21-
22-
23 m_network = engine->v8Engine->networkAccessManager();-
24-
25 QNetworkRequest request;-
26 request.setUrl(url);-
27-
28 m_reply = m_network->get(request);-
29 QObject::connect(m_reply, qFlagLocation("2""finished()" "\0" __FILE__ ":" "81"), this, qFlagLocation("1""finished()" "\0" __FILE__ ":" "81"));-
30-
31-
32-
33}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
6
34-
35QV4Include::~QV4Include()-
36{-
37-
38 delete m_reply;-
39 m_reply = nullptr;-
40-
41}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
6
42-
43QV4::ReturnedValue QV4Include::resultValue(QV4::ExecutionEngine *v4, Status status,-
44 const QString &statusText)-
45{-
46 QV4::Scope scope(v4);-
47-
48-
49 QV4::ScopedObject o(scope, v4->newObject());-
50 QV4::ScopedString s(scope);-
51 QV4::ScopedValue v(scope);-
52 o->put((s = v4->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "OK")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "OK" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 30 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
qstring_literal_temp;
executed 30 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
}()))), (v = QV4::Primitive::fromInt32(Ok)));
30
53 o->put((s = v4->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "LOADING")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "LOADING" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 30 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
qstring_literal_temp;
executed 30 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
}()))), (v = QV4::Primitive::fromInt32(Loading)));
30
54 o->put((s = v4->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "NETWORK_ERROR")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "NETWORK_ERROR" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 30 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
qstring_literal_temp;
executed 30 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
}()))), (v = QV4::Primitive::fromInt32(NetworkError)));
30
55 o->put((s = v4->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "EXCEPTION")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "EXCEPTION" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 30 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
qstring_literal_temp;
executed 30 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
}()))), (v = QV4::Primitive::fromInt32(Exception)));
30
56 o->put((s = v4->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "status")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "status" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 30 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
qstring_literal_temp;
executed 30 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
}()))), (v = QV4::Primitive::fromInt32(status)));
30
57 if (!statusText.isEmpty()
!statusText.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEevaluated 28 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
)
2-28
58 o->put((s = v4->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "statusText")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "statusText" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 2 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qqmlecmascript
qstring_literal_temp;
executed 2 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qqmlecmascript
}()))), (v = v4->newString(statusText)));
executed 2 times by 1 test: o->put((s = v4->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "statusText")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "statusText" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()))), (v = v4->newString(statusText)));
Executed by:
  • tst_qqmlecmascript
2
59-
60 return
executed 30 times by 3 tests: return o.asReturnedValue();
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
o.asReturnedValue();
executed 30 times by 3 tests: return o.asReturnedValue();
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
30
61}-
62-
63void QV4Include::callback(const QV4::Value &callback, const QV4::Value &status)-
64{-
65 if (!callback.isObject()
!callback.isObject()Description
TRUEevaluated 18 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
)
12-18
66 return;
executed 18 times by 3 tests: return;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
18
67 QV4::ExecutionEngine *v4 = callback.as<QV4::Object>()->engine();-
68 QV4::Scope scope(v4);-
69 QV4::ScopedFunctionObject f(scope, callback);-
70 if (!f
!fDescription
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
)
0-12
71 return;
never executed: return;
0
72-
73 QV4::JSCallData jsCallData(scope, 1);-
74 *jsCallData->thisObject = v4->globalObject->asReturnedValue();-
75 jsCallData->args[0] = status;-
76 f->call(jsCallData);-
77 if (scope.hasException()
scope.hasException()Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
)
0-12
78 scope.engine->catchException();
never executed: scope.engine->catchException();
0
79}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
12
80-
81QV4::ReturnedValue QV4Include::result()-
82{-
83 return
executed 6 times by 1 test: return m_resultObject.value();
Executed by:
  • tst_qqmlecmascript
m_resultObject.value();
executed 6 times by 1 test: return m_resultObject.value();
Executed by:
  • tst_qqmlecmascript
6
84}-
85-
86-
87void QV4Include::finished()-
88{-
89-
90 m_redirectCount++;-
91-
92 if (m_redirectCount < 15
m_redirectCount < 15Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
) {
0-6
93 QVariant redirect = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute);-
94 if (redirect.isValid()
redirect.isValid()Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
) {
0-6
95 m_url = m_url.resolved(redirect.toUrl());-
96 delete m_reply;-
97-
98 QNetworkRequest request;-
99 request.setUrl(m_url);-
100-
101 m_reply = m_network->get(request);-
102 QObject::connect(m_reply, qFlagLocation("2""finished()" "\0" __FILE__ ":" "154"), this, qFlagLocation("1""finished()" "\0" __FILE__ ":" "154"));-
103 return;
never executed: return;
0
104 }-
105 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
6
106-
107 QV4::Scope scope(v4);-
108 QV4::ScopedObject resultObj(scope, m_resultObject.value());-
109 QV4::ScopedString status(scope, v4->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "status")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "status" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 6 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qqmlecmascript
qstring_literal_temp;
executed 6 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qqmlecmascript
}())));
6
110 if (m_reply->error() == QNetworkReply::NoError
m_reply->error...Reply::NoErrorDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
) {
2-4
111 QByteArray data = m_reply->readAll();-
112-
113 QString code = QString::fromUtf8(data);-
114 QmlIR::Document::removeScriptPragmas(code);-
115-
116 QV4::Scoped<QV4::QmlContext> qml(scope, m_qmlContext.value());-
117 QV4::Script script(v4, qml, code, m_url.toString());-
118-
119 script.parse();-
120 if (!scope.engine->hasException
!scope.engine->hasExceptionDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
)
0-4
121 script.run();
executed 4 times by 1 test: script.run();
Executed by:
  • tst_qqmlecmascript
4
122 if (scope.engine->hasException
scope.engine->hasExceptionDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
) {
2
123 QV4::ScopedValue ex(scope, scope.engine->catchException());-
124 resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Exception)));-
125 QV4::ScopedString exception(scope, v4->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "exception")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "exception" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 2 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qqmlecmascript
qstring_literal_temp;
executed 2 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qqmlecmascript
}())));
2
126 resultObj->put(exception, ex);-
127 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
else {
2
128 resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Ok)));-
129 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
2
130 } else {-
131 resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(NetworkError)));-
132 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
2
133-
134-
135-
136-
137-
138-
139-
140 QV4::ScopedValue cb(scope, m_callbackFunction.value());-
141 callback(cb, resultObj);-
142-
143 disconnect();-
144 deleteLater();-
145}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
6
146-
147-
148-
149-
150QV4::ReturnedValue QV4Include::method_include(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *argv, int argc)-
151{-
152 QV4::Scope scope(b);-
153 if (!argc
!argcDescription
TRUEnever evaluated
FALSEevaluated 30 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
)
0-30
154 return
never executed: return QV4::Encode::undefined();
QV4::Encode::undefined();
never executed: return QV4::Encode::undefined();
0
155-
156 QQmlContextData *context = scope.engine->callingQmlContext();-
157-
158 if (!context
!contextDescription
TRUEnever evaluated
FALSEevaluated 30 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
|| !context->isJSContext
!context->isJSContextDescription
TRUEnever evaluated
FALSEevaluated 30 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
)
0-30
159 return
never executed: return QV4::Encode(scope.engine->throwError(QString::fromUtf8("Qt.include(): Can only be called from JavaScript files")));
QV4::Encode(scope.engine->throwError(QString::fromUtf8("Qt.include(): Can only be called from JavaScript files")));
never executed: return QV4::Encode(scope.engine->throwError(QString::fromUtf8("Qt.include(): Can only be called from JavaScript files")));
0
160-
161 QV4::ScopedValue callbackFunction(scope, QV4::Primitive::undefinedValue());-
162 if (argc >= 2
argc >= 2Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEevaluated 18 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
&& argv[1].as<QV4::FunctionObject>()
argv[1].as<QV4...ctionObject>()Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
)
0-18
163 callbackFunction = argv[1];
executed 12 times by 1 test: callbackFunction = argv[1];
Executed by:
  • tst_qqmlecmascript
12
164-
165-
166 QUrl url(scope.engine->resolvedUrl(argv[0].toQStringNoThrow()));-
167 if (scope.engine->qmlEngine()
scope.engine->qmlEngine()Description
TRUEevaluated 28 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickworkerscript
&& scope.engine->qmlEngine()->urlInterceptor()
scope.engine->...lInterceptor()Description
TRUEnever evaluated
FALSEevaluated 28 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
)
0-28
168 url = scope.engine->qmlEngine()->urlInterceptor()->intercept(url, QQmlAbstractUrlInterceptor::JavaScriptFile);
never executed: url = scope.engine->qmlEngine()->urlInterceptor()->intercept(url, QQmlAbstractUrlInterceptor::JavaScriptFile);
0
169-
170 QString localFile = QQmlFile::urlToLocalFileOrQrc(url);-
171-
172 QV4::ScopedValue result(scope);-
173 QV4::Scoped<QV4::QmlContext> qmlcontext(scope, scope.engine->qmlContext());-
174-
175 if (localFile.isEmpty()
localFile.isEmpty()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEevaluated 24 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
) {
6-24
176 QV4Include *i = new QV4Include(url, scope.engine, qmlcontext, callbackFunction);-
177 result = i->result();-
178-
179 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
else {
6
180 QScopedPointer<QV4::Script> script;-
181 QString error;-
182 script.reset(QV4::Script::createFromFileOrCache(scope.engine, qmlcontext, localFile, url, &error));-
183-
184 if (!script.isNull()
!script.isNull()Description
TRUEevaluated 22 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
) {
2-22
185 script->parse();-
186 if (!scope.engine->hasException
!scope.engine->hasExceptionDescription
TRUEevaluated 22 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
FALSEnever evaluated
)
0-22
187 script->run();
executed 22 times by 3 tests: script->run();
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
22
188 if (scope.engine->hasException
scope.engine->hasExceptionDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEevaluated 20 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
) {
2-20
189 QV4::ScopedValue ex(scope, scope.engine->catchException());-
190 result = resultValue(scope.engine, Exception);-
191 QV4::ScopedString exception(scope, scope.engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "exception")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "exception" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 2 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qqmlecmascript
qstring_literal_temp;
executed 2 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qqmlecmascript
}())));
2
192 result->as<QV4::Object>()->put(exception, ex);-
193 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
else {
2
194 result = resultValue(scope.engine, Ok);-
195 }
executed 20 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
20
196 } else {-
197 result = resultValue(scope.engine, NetworkError, error);-
198 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
2
199-
200 callback(callbackFunction, result);-
201 }
executed 24 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
24
202-
203-
204-
205-
206-
207-
208-
209 return
executed 30 times by 3 tests: return result->asReturnedValue();
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
result->asReturnedValue();
executed 30 times by 3 tests: return result->asReturnedValue();
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
30
210}-
211-
212-
213-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0