aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeworkerscript
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-06-07 16:34:04 +1000
committerAaron Kennedy <aaron.kennedy@nokia.com>2011-06-07 17:00:11 +1000
commit53085399f56714db27cbdebe554146528d13c94e (patch)
tree3706a9938f7c2c2dbc13d77c07ffdc4c81b4185e /tests/auto/declarative/qdeclarativeworkerscript
parent1c3dd8f22da09bf9a110715d159374a09c27dc77 (diff)
Dispose of WorkerScripts in correct Isolate
We were disposing them in the main thread isolate which caused corruption of the v8 heap. Specifically this showed in asserting allocations of persistent handles.
Diffstat (limited to 'tests/auto/declarative/qdeclarativeworkerscript')
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js6
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml13
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp13
3 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js b/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js
new file mode 100644
index 0000000000..5c4c5ec906
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js
@@ -0,0 +1,6 @@
+WorkerScript.onMessage = function() {
+}
+for (var ii = 0; ii < 100; ++ii) {
+ var a = "HELLO WORLD";
+}
+
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml
new file mode 100644
index 0000000000..d05918a074
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml
@@ -0,0 +1,13 @@
+import QtQuick 1.0
+
+Item {
+ WorkerScript {
+ id: worker
+ source: "stressDispose.js"
+ }
+
+ Component.onCompleted: {
+ worker.sendMessage(10);
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
index dd99a18ce3..2c85040f5f 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
+++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
@@ -80,6 +80,7 @@ private slots:
void script_included();
void scriptError_onLoad();
void scriptError_onCall();
+ void stressDispose();
private:
void waitForEchoMessage(QDeclarativeWorkerScript *worker) {
@@ -283,6 +284,18 @@ void tst_QDeclarativeWorkerScript::scriptError_onCall()
delete worker;
}
+// Rapidly create and destroy worker scripts to test resources are being disposed
+// in the correct isolate
+void tst_QDeclarativeWorkerScript::stressDispose()
+{
+ for (int ii = 0; ii < 100; ++ii) {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, SRCDIR "/data/stressDispose.qml");
+ QObject *o = component.create();
+ QVERIFY(o);
+ delete o;
+ }
+}
QTEST_MAIN(tst_QDeclarativeWorkerScript)