Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / automation / tests / desktop / common.js
index 61d5a6b..65c79d6 100644 (file)
@@ -25,9 +25,31 @@ function findAutomationNode(root, condition) {
   return null;
 }
 
-function setupAndRunTests(allTests) {
-  chrome.automation.getDesktop(function(rootNodeArg) {
-    rootNode = rootNodeArg;
-    chrome.test.runTests(allTests);
+function runWithDocument(docString, callback) {
+  var url = 'data:text/html,<!doctype html>' + docString;
+  var createParams = {
+    active: true,
+    url: url
+  };
+  chrome.tabs.create(createParams, function(tab) {
+    chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) {
+      if (tabId == tab.id && changeInfo.status == 'complete') {
+        callback();
+      }
+    });
   });
 }
+
+function setupAndRunTests(allTests, opt_docString) {
+  function runTestInternal() {
+    chrome.automation.getDesktop(function(rootNodeArg) {
+      rootNode = rootNodeArg;
+      chrome.test.runTests(allTests);
+    });
+  }
+
+  if (opt_docString)
+    runWithDocument(opt_docString, runTestInternal);
+  else
+    runTestInternal();
+}