Move mojo/apps/js tests et al to mojo/edk/js/test,tests

The apps_js_unitttests test executable is now called js_integration_tests.

The connection_unittests are now included in the JS unittests. To enable that the threading module, which just provides a quit method, was added to mojo/public/js. Its implementation is mojo/edk/js.

Integration tests are in the edk/js/tests directory and test support code is in edk/js/test.

BUG=430520
R=jamesr@chromium.org

Review URL: https://codereview.chromium.org/709603002
diff --git a/mojo/BUILD.gn b/mojo/BUILD.gn
index 6595b13..6851110 100644
--- a/mojo/BUILD.gn
+++ b/mojo/BUILD.gn
@@ -64,10 +64,10 @@
   testonly = true
   deps = [
     "//mojo/application_manager:mojo_application_manager_unittests",
-    "//mojo/apps/js/test:apps_js_unittests",
     "//mojo/common:mojo_common_unittests",
     "//mojo/converters/surfaces/tests:mojo_surfaces_lib_unittests",
-    "//mojo/edk/js/tests:js_unittests",
+    "//mojo/edk/js/test:js_unittests",
+    "//mojo/edk/js/test:js_integration_tests",
     "//mojo/edk/system:mojo_message_pipe_perftests",
     "//mojo/edk/system:mojo_system_unittests",
     "//mojo/public/c/system/tests:perftests",
diff --git a/mojo/apps/js/BUILD.gn b/mojo/apps/js/BUILD.gn
index fe0b8b4..6b32936 100644
--- a/mojo/apps/js/BUILD.gn
+++ b/mojo/apps/js/BUILD.gn
@@ -10,24 +10,6 @@
   ]
 }
 
-source_set("mojo_runner") {
-  sources = [
-    "mojo_runner_delegate.cc",
-    "mojo_runner_delegate.h",
-  ]
-
-  public_deps = [
-    "//mojo/edk/js",
-  ]
-  deps = [
-    "//base",
-    "//gin",
-    "//mojo/apps/js/bindings",
-    "//mojo/apps/js/bindings/gl",
-    "//v8",
-  ]
-}
-
 source_set("js_apps") {
   sources = [
     "js_app.cc",
@@ -38,7 +20,6 @@
     "//mojo/edk/js",
   ]
   deps = [
-    ":mojo_runner",
     "//mojo/application",
     "//mojo/public/c/system:for_shared_library",
     "//mojo/public/cpp/utility",
diff --git a/mojo/apps/js/bindings/BUILD.gn b/mojo/apps/js/bindings/BUILD.gn
index b17d437..6bfce88 100644
--- a/mojo/apps/js/bindings/BUILD.gn
+++ b/mojo/apps/js/bindings/BUILD.gn
@@ -11,8 +11,6 @@
   ]
 
   sources = [
-    "threading.cc",
-    "threading.h",
     "monotonic_clock.cc",
     "monotonic_clock.h",
   ]
diff --git a/mojo/apps/js/js_app.h b/mojo/apps/js/js_app.h
index 04cb759..d284b0d 100644
--- a/mojo/apps/js/js_app.h
+++ b/mojo/apps/js/js_app.h
@@ -10,7 +10,7 @@
 #include "gin/public/isolate_holder.h"
 #include "gin/shell_runner.h"
 #include "mojo/application/content_handler_factory.h"
-#include "mojo/apps/js/mojo_runner_delegate.h"
+#include "mojo/edk/js/mojo_runner_delegate.h"
 #include "mojo/public/cpp/application/application_delegate.h"
 #include "mojo/public/interfaces/application/application.mojom.h"
 #include "mojo/public/interfaces/application/shell.mojom.h"
@@ -50,7 +50,7 @@
   void QuitInternal();
 
   ShellPtr shell_;
-  MojoRunnerDelegate runner_delegate;
+  js::MojoRunnerDelegate runner_delegate;
   gin::IsolateHolder isolate_holder_;
   scoped_ptr<gin::ShellRunner> shell_runner_;
   std::string source_;
diff --git a/mojo/apps/js/test/BUILD.gn b/mojo/apps/js/test/BUILD.gn
index 1777700..c0da7bf 100644
--- a/mojo/apps/js/test/BUILD.gn
+++ b/mojo/apps/js/test/BUILD.gn
@@ -2,13 +2,9 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-import("//mojo/public/tools/bindings/mojom.gni")
-
 test("apps_js_unittests") {
   deps = [
-    ":js_to_cpp_bindings",
     "//gin:gin_test",
-    "//mojo/apps/js:mojo_runner",
     "//mojo/apps/js/bindings",
     "//mojo/edk/js",
     "//mojo/common",
@@ -20,11 +16,6 @@
   ]
 
   sources = [
-    "js_to_cpp_unittest.cc",
     "run_apps_js_tests.cc",
   ]
 }
-
-mojom("js_to_cpp_bindings") {
-  sources = [ "js_to_cpp.mojom" ]
-}
diff --git a/mojo/apps/js/test/run_apps_js_tests.cc b/mojo/apps/js/test/run_apps_js_tests.cc
index 3ccfd71..5d599a5 100644
--- a/mojo/apps/js/test/run_apps_js_tests.cc
+++ b/mojo/apps/js/test/run_apps_js_tests.cc
@@ -10,7 +10,6 @@
 #include "gin/test/file_runner.h"
 #include "gin/test/gtest.h"
 #include "mojo/apps/js/bindings/monotonic_clock.h"
-#include "mojo/apps/js/bindings/threading.h"
 #include "mojo/edk/js/core.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -26,7 +25,6 @@
     AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule);
     AddBuiltinModule(apps::MonotonicClock::kModuleName,
                      apps::MonotonicClock::GetModule);
-    AddBuiltinModule(apps::Threading::kModuleName, apps::Threading::GetModule);
   }
 
  private:
@@ -47,14 +45,6 @@
 
 // TODO(abarth): Should we autogenerate these stubs from GYP?
 
-TEST(JSTest, sample_test) {
-  RunTest("sample_service_unittests.js", true);
-}
-
-TEST(JSTest, connection) {
-  RunTest("connection_unittests.js", false);
-}
-
 TEST(JSTest, monotonic_clock) {
   RunTest("monotonic_clock_unittests.js", false);
 }
diff --git a/mojo/edk/js/BUILD.gn b/mojo/edk/js/BUILD.gn
index b8d60ec..bc00649 100644
--- a/mojo/edk/js/BUILD.gn
+++ b/mojo/edk/js/BUILD.gn
@@ -11,8 +11,12 @@
     "handle.cc",
     "handle.h",
     "handle_close_observer.h",
+    "mojo_runner_delegate.cc",
+    "mojo_runner_delegate.h",
     "support.cc",
     "support.h",
+    "threading.cc",
+    "threading.h",
     "waiting_callback.cc",
     "waiting_callback.h",
   ]
diff --git a/mojo/edk/js/DEPS b/mojo/edk/js/DEPS
index d974b68..c350edf 100644
--- a/mojo/edk/js/DEPS
+++ b/mojo/edk/js/DEPS
@@ -1,4 +1,5 @@
 include_rules = [
+  "+base",
   "+gin",
   "+v8",
 ]
diff --git a/mojo/edk/js/core.h b/mojo/edk/js/core.h
index bde327c..445fb00 100644
--- a/mojo/edk/js/core.h
+++ b/mojo/edk/js/core.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_BINDINGS_JS_CORE_H_
-#define MOJO_BINDINGS_JS_CORE_H_
+#ifndef MOJO_EDK_JS_CORE_H_
+#define MOJO_EDK_JS_CORE_H_
 
 #include "v8/include/v8.h"
 
@@ -19,4 +19,4 @@
 }  // namespace js
 }  // namespace mojo
 
-#endif  // MOJO_BINDINGS_JS_CORE_H_
+#endif  // MOJO_EDK_JS_CORE_H_
diff --git a/mojo/edk/js/drain_data.h b/mojo/edk/js/drain_data.h
index 27d8f52..48f1de2 100644
--- a/mojo/edk/js/drain_data.h
+++ b/mojo/edk/js/drain_data.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_BINDINGS_JS_DRAIN_DATA_H_
-#define MOJO_BINDINGS_JS_DRAIN_DATA_H_
+#ifndef MOJO_EDK_JS_DRAIN_DATA_H_
+#define MOJO_EDK_JS_DRAIN_DATA_H_
 
 #include "base/memory/scoped_vector.h"
 #include "gin/runner.h"
@@ -61,4 +61,4 @@
 }  // namespace js
 }  // namespace mojo
 
-#endif  // MOJO_BINDINGS_JS_DRAIN_DATA_H_
+#endif  // MOJO_EDK_JS_DRAIN_DATA_H_
diff --git a/mojo/edk/js/handle.h b/mojo/edk/js/handle.h
index e363b7c..c60a396 100644
--- a/mojo/edk/js/handle.h
+++ b/mojo/edk/js/handle.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_BINDINGS_JS_HANDLE_H_
-#define MOJO_BINDINGS_JS_HANDLE_H_
+#ifndef MOJO_EDK_JS_HANDLE_H_
+#define MOJO_EDK_JS_HANDLE_H_
 
 #include "base/observer_list.h"
 #include "gin/converter.h"
@@ -101,4 +101,4 @@
 
 }  // namespace gin
 
-#endif  // MOJO_BINDINGS_JS_HANDLE_H_
+#endif  // MOJO_EDK_JS_HANDLE_H_
diff --git a/mojo/edk/js/handle_close_observer.h b/mojo/edk/js/handle_close_observer.h
index 8f19466..3e537fd 100644
--- a/mojo/edk/js/handle_close_observer.h
+++ b/mojo/edk/js/handle_close_observer.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_BINDINGS_JS_HANDLE_CLOSE_OBSERVER_H_
-#define MOJO_BINDINGS_JS_HANDLE_CLOSE_OBSERVER_H_
+#ifndef MOJO_EDK_JS_HANDLE_CLOSE_OBSERVER_H_
+#define MOJO_EDK_JS_HANDLE_CLOSE_OBSERVER_H_
 
 namespace mojo {
 namespace js {
@@ -19,4 +19,4 @@
 }  // namespace js
 }  // namespace mojo
 
-#endif  // MOJO_BINDINGS_JS_HANDLE_CLOSE_OBSERVER_H_
+#endif  // MOJO_EDK_JS_HANDLE_CLOSE_OBSERVER_H_
diff --git a/mojo/apps/js/mojo_runner_delegate.cc b/mojo/edk/js/mojo_runner_delegate.cc
similarity index 85%
rename from mojo/apps/js/mojo_runner_delegate.cc
rename to mojo/edk/js/mojo_runner_delegate.cc
index 078d500..152b12c 100644
--- a/mojo/apps/js/mojo_runner_delegate.cc
+++ b/mojo/edk/js/mojo_runner_delegate.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "mojo/apps/js/mojo_runner_delegate.h"
+#include "mojo/edk/js/mojo_runner_delegate.h"
 
 #include "base/bind.h"
 #include "base/path_service.h"
@@ -11,15 +11,13 @@
 #include "gin/modules/module_registry.h"
 #include "gin/modules/timer.h"
 #include "gin/try_catch.h"
-#include "mojo/apps/js/bindings/gl/module.h"
-#include "mojo/apps/js/bindings/monotonic_clock.h"
-#include "mojo/apps/js/bindings/threading.h"
 #include "mojo/edk/js/core.h"
 #include "mojo/edk/js/handle.h"
 #include "mojo/edk/js/support.h"
+#include "mojo/edk/js/threading.h"
 
 namespace mojo {
-namespace apps {
+namespace js {
 
 namespace {
 
@@ -53,9 +51,7 @@
   AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule);
   AddBuiltinModule(js::Core::kModuleName, js::Core::GetModule);
   AddBuiltinModule(js::Support::kModuleName, js::Support::GetModule);
-  AddBuiltinModule(js::gl::kModuleName, js::gl::GetModule);
-  AddBuiltinModule(MonotonicClock::kModuleName, MonotonicClock::GetModule);
-  AddBuiltinModule(Threading::kModuleName, Threading::GetModule);
+  AddBuiltinModule(js::Threading::kModuleName, js::Threading::GetModule);
 }
 
 MojoRunnerDelegate::~MojoRunnerDelegate() {
@@ -78,5 +74,5 @@
   LOG(ERROR) << try_catch.GetStackTrace();
 }
 
-}  // namespace apps
+}  // namespace js
 }  // namespace mojo
diff --git a/mojo/apps/js/mojo_runner_delegate.h b/mojo/edk/js/mojo_runner_delegate.h
similarity index 80%
rename from mojo/apps/js/mojo_runner_delegate.h
rename to mojo/edk/js/mojo_runner_delegate.h
index ddc9598..423eefb 100644
--- a/mojo/apps/js/mojo_runner_delegate.h
+++ b/mojo/edk/js/mojo_runner_delegate.h
@@ -2,15 +2,15 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_APPS_JS_MOJO_RUNNER_DELEGATE_H_
-#define MOJO_APPS_JS_MOJO_RUNNER_DELEGATE_H_
+#ifndef MOJO_EDK_JS_MOJO_RUNNER_DELEGATE_H_
+#define MOJO_EDK_JS_MOJO_RUNNER_DELEGATE_H_
 
 #include "base/macros.h"
 #include "gin/modules/module_runner_delegate.h"
 #include "mojo/public/c/system/core.h"
 
 namespace mojo {
-namespace apps {
+namespace js {
 
 class MojoRunnerDelegate : public gin::ModuleRunnerDelegate {
  public:
@@ -27,7 +27,7 @@
   DISALLOW_COPY_AND_ASSIGN(MojoRunnerDelegate);
 };
 
-}  // namespace apps
+}  // namespace js
 }  // namespace mojo
 
-#endif  // MOJO_APPS_JS_MOJO_RUNNER_DELEGATE_H_
+#endif  // MOJO_EDK_JS_MOJO_RUNNER_DELEGATE_H_
diff --git a/mojo/edk/js/support.h b/mojo/edk/js/support.h
index 0f6eb07..b49dd23 100644
--- a/mojo/edk/js/support.h
+++ b/mojo/edk/js/support.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_BINDINGS_JS_SUPPORT_H_
-#define MOJO_BINDINGS_JS_SUPPORT_H_
+#ifndef MOJO_EDK_JS_SUPPORT_H_
+#define MOJO_EDK_JS_SUPPORT_H_
 
 #include "v8/include/v8.h"
 
@@ -19,4 +19,4 @@
 }  // namespace js
 }  // namespace mojo
 
-#endif  // MOJO_BINDINGS_JS_SUPPORT_H_
+#endif  // MOJO_EDK_JS_SUPPORT_H_
diff --git a/mojo/edk/js/test/BUILD.gn b/mojo/edk/js/test/BUILD.gn
new file mode 100644
index 0000000..830e3b0
--- /dev/null
+++ b/mojo/edk/js/test/BUILD.gn
@@ -0,0 +1,36 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+test("js_unittests") {
+  deps = [
+    "//base",
+    "//gin:gin_test",
+    "//mojo/edk/js",
+    "//mojo/edk/test:run_all_unittests",
+    "//mojo/edk/test:test_support",
+    "//mojo/public/cpp/utility",
+    "//mojo/environment:chromium",
+    "//mojo/public/interfaces/bindings/tests:test_interfaces",
+  ]
+
+  sources = [ "run_js_tests.cc" ]
+}
+
+test("js_integration_tests") {
+  deps = [
+    "//base",
+    "//gin:gin_test",
+    "//mojo/edk/js",
+    "//mojo/edk/js/tests:js_to_cpp_tests",
+    "//mojo/edk/test:run_all_unittests",
+    "//mojo/edk/test:test_support",
+    "//mojo/public/cpp/bindings",
+    "//mojo/environment:chromium",
+    "//mojo/public/interfaces/bindings/tests:test_interfaces",
+  ]
+
+  sources = [
+    "run_js_integration_tests.cc"
+  ]
+}
diff --git a/mojo/apps/js/test/hexdump.js b/mojo/edk/js/test/hexdump.js
similarity index 100%
rename from mojo/apps/js/test/hexdump.js
rename to mojo/edk/js/test/hexdump.js
diff --git a/mojo/edk/js/tests/run_js_tests.cc b/mojo/edk/js/test/run_js_integration_tests.cc
similarity index 64%
copy from mojo/edk/js/tests/run_js_tests.cc
copy to mojo/edk/js/test/run_js_integration_tests.cc
index 4246f8e..1a6f1d6 100644
--- a/mojo/edk/js/tests/run_js_tests.cc
+++ b/mojo/edk/js/test/run_js_integration_tests.cc
@@ -11,7 +11,7 @@
 #include "gin/test/gtest.h"
 #include "mojo/edk/js/core.h"
 #include "mojo/edk/js/support.h"
-#include "mojo/public/cpp/environment/environment.h"
+#include "mojo/edk/js/threading.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace mojo {
@@ -23,40 +23,33 @@
   TestRunnerDelegate() {
     AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule);
     AddBuiltinModule(Core::kModuleName, Core::GetModule);
-    AddBuiltinModule(Support::kModuleName, Support::GetModule);
+    AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule);
+    AddBuiltinModule(Threading::kModuleName, Threading::GetModule);
   }
-
  private:
   DISALLOW_COPY_AND_ASSIGN(TestRunnerDelegate);
 };
 
-void RunTest(std::string test, bool run_until_idle) {
-  Environment env;
+void RunTest(std::string test, bool addSupportModule) {
   base::FilePath path;
   PathService::Get(base::DIR_SOURCE_ROOT, &path);
   path = path.AppendASCII("mojo")
-             .AppendASCII("public")
+             .AppendASCII("edk")
              .AppendASCII("js")
+             .AppendASCII("tests")
              .AppendASCII(test);
   TestRunnerDelegate delegate;
-  gin::RunTestFromFile(path, &delegate, run_until_idle);
+  if (addSupportModule)
+    delegate.AddBuiltinModule(Support::kModuleName, Support::GetModule);
+  gin::RunTestFromFile(path, &delegate, true);
 }
 
-// TODO(abarth): Should we autogenerate these stubs from GYP?
-TEST(JSTest, core) {
-  RunTest("core_unittests.js", true);
+TEST(JSTest, connection) {
+  RunTest("connection_tests.js", false);
 }
 
-TEST(JSTest, codec) {
-  RunTest("codec_unittests.js", true);
-}
-
-TEST(JSTest, struct) {
-  RunTest("struct_unittests.js", true);
-}
-
-TEST(JSTest, validation) {
-  RunTest("validation_unittests.js", true);
+TEST(JSTest, sample_service) {
+  RunTest("sample_service_tests.js", true);
 }
 
 }  // namespace
diff --git a/mojo/edk/js/tests/run_js_tests.cc b/mojo/edk/js/test/run_js_tests.cc
similarity index 96%
rename from mojo/edk/js/tests/run_js_tests.cc
rename to mojo/edk/js/test/run_js_tests.cc
index 4246f8e..b574902 100644
--- a/mojo/edk/js/tests/run_js_tests.cc
+++ b/mojo/edk/js/test/run_js_tests.cc
@@ -6,7 +6,6 @@
 #include "base/path_service.h"
 #include "gin/modules/console.h"
 #include "gin/modules/module_registry.h"
-#include "gin/modules/timer.h"
 #include "gin/test/file_runner.h"
 #include "gin/test/gtest.h"
 #include "mojo/edk/js/core.h"
@@ -31,7 +30,6 @@
 };
 
 void RunTest(std::string test, bool run_until_idle) {
-  Environment env;
   base::FilePath path;
   PathService::Get(base::DIR_SOURCE_ROOT, &path);
   path = path.AppendASCII("mojo")
diff --git a/mojo/edk/js/tests/BUILD.gn b/mojo/edk/js/tests/BUILD.gn
index 1555328..7e3f19d 100644
--- a/mojo/edk/js/tests/BUILD.gn
+++ b/mojo/edk/js/tests/BUILD.gn
@@ -2,17 +2,25 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-test("js_unittests") {
+import("//mojo/public/tools/bindings/mojom.gni")
+
+source_set("js_to_cpp_tests") {
+  testonly = true
+
   deps = [
+    ":js_to_cpp_bindings",
     "//gin:gin_test",
     "//mojo/edk/js",
-    "//mojo/edk/js:js_unittests",
-    "//mojo/edk/test:run_all_unittests",
     "//mojo/edk/test:test_support",
-    "//mojo/public/cpp/environment:standalone",
-    "//mojo/public/cpp/utility",
+    "//mojo/public/cpp/bindings",
     "//mojo/public/interfaces/bindings/tests:test_interfaces",
   ]
 
-  sources = [ "run_js_tests.cc" ]
+  sources = [
+    "js_to_cpp_tests.cc",
+  ]
+}
+
+mojom("js_to_cpp_bindings") {
+  sources = [ "js_to_cpp.mojom" ]
 }
diff --git a/mojo/edk/js/tests/DEPS b/mojo/edk/js/tests/DEPS
deleted file mode 100644
index 2424ea1..0000000
--- a/mojo/edk/js/tests/DEPS
+++ /dev/null
@@ -1,7 +0,0 @@
-include_rules = [
-  "+base",
-  "+gin",
-  "+v8",
-  "+mojo/bindings/js/core.h",
-  "+mojo/bindings/js/support.h",
-]
diff --git a/mojo/apps/js/bindings/connection_unittests.js b/mojo/edk/js/tests/connection_tests.js
similarity index 98%
rename from mojo/apps/js/bindings/connection_unittests.js
rename to mojo/edk/js/tests/connection_tests.js
index be325f9..6649dfe 100644
--- a/mojo/apps/js/bindings/connection_unittests.js
+++ b/mojo/edk/js/tests/connection_tests.js
@@ -60,7 +60,7 @@
     "mojo/public/js/connection",
     "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom",
     "mojo/public/interfaces/bindings/tests/sample_service.mojom",
-    "mojo/apps/js/bindings/threading",
+    "mojo/public/js/threading",
     "gc",
 ], function(expect,
             mockSupport,
diff --git a/mojo/apps/js/test/js_to_cpp.mojom b/mojo/edk/js/tests/js_to_cpp.mojom
similarity index 100%
rename from mojo/apps/js/test/js_to_cpp.mojom
rename to mojo/edk/js/tests/js_to_cpp.mojom
diff --git a/mojo/apps/js/test/js_to_cpp_unittest.cc b/mojo/edk/js/tests/js_to_cpp_tests.cc
similarity index 91%
rename from mojo/apps/js/test/js_to_cpp_unittest.cc
rename to mojo/edk/js/tests/js_to_cpp_tests.cc
index 0c44b75..1da70c2 100644
--- a/mojo/apps/js/test/js_to_cpp_unittest.cc
+++ b/mojo/edk/js/tests/js_to_cpp_tests.cc
@@ -11,9 +11,8 @@
 #include "base/strings/utf_string_conversions.h"
 #include "gin/array_buffer.h"
 #include "gin/public/isolate_holder.h"
-#include "mojo/apps/js/mojo_runner_delegate.h"
-#include "mojo/apps/js/test/js_to_cpp.mojom.h"
-#include "mojo/common/common_type_converters.h"
+#include "mojo/edk/js/mojo_runner_delegate.h"
+#include "mojo/edk/js/tests/js_to_cpp.mojom.h"
 #include "mojo/edk/test/test_utils.h"
 #include "mojo/public/cpp/system/core.h"
 #include "mojo/public/cpp/system/macros.h"
@@ -53,19 +52,6 @@
 // NaN has the property that it is not equal to itself.
 #define EXPECT_NAN(x) EXPECT_NE(x, x)
 
-bool IsRunningOnIsolatedBot() {
-  // TODO(yzshen): Remove this check once isolated tests are supported on the
-  // Chromium waterfall. (http://crbug.com/351214)
-  const base::FilePath test_file_path(
-      test::GetFilePathForJSResource(
-          "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom"));
-  if (!base::PathExists(test_file_path)) {
-    LOG(WARNING) << "Mojom binding files don't exist. Skipping the test.";
-    return true;
-  }
-  return false;
-}
-
 void CheckDataPipe(MojoHandle data_pipe_handle) {
   unsigned char buffer[100];
   uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer));
@@ -389,7 +375,7 @@
     gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
                                    gin::ArrayBufferAllocator::SharedInstance());
     gin::IsolateHolder instance;
-    apps::MojoRunnerDelegate delegate;
+    MojoRunnerDelegate delegate;
     gin::ShellRunner runner(&delegate, instance.isolate());
     delegate.Start(&runner, pipe.handle1.release().value(), test);
 
@@ -405,38 +391,26 @@
 };
 
 TEST_F(JsToCppTest, Ping) {
-  if (IsRunningOnIsolatedBot())
-    return;
-
   PingCppSideConnection cpp_side_connection;
-  RunTest("mojo/apps/js/test/js_to_cpp_unittest", &cpp_side_connection);
+  RunTest("mojo/edk/js/tests/js_to_cpp_tests", &cpp_side_connection);
   EXPECT_TRUE(cpp_side_connection.DidSucceed());
 }
 
 TEST_F(JsToCppTest, Echo) {
-  if (IsRunningOnIsolatedBot())
-    return;
-
   EchoCppSideConnection cpp_side_connection;
-  RunTest("mojo/apps/js/test/js_to_cpp_unittest", &cpp_side_connection);
+  RunTest("mojo/edk/js/tests/js_to_cpp_tests", &cpp_side_connection);
   EXPECT_TRUE(cpp_side_connection.DidSucceed());
 }
 
 TEST_F(JsToCppTest, BitFlip) {
-  if (IsRunningOnIsolatedBot())
-    return;
-
   BitFlipCppSideConnection cpp_side_connection;
-  RunTest("mojo/apps/js/test/js_to_cpp_unittest", &cpp_side_connection);
+  RunTest("mojo/edk/js/tests/js_to_cpp_tests", &cpp_side_connection);
   EXPECT_TRUE(cpp_side_connection.DidSucceed());
 }
 
 TEST_F(JsToCppTest, BackPointer) {
-  if (IsRunningOnIsolatedBot())
-    return;
-
   BackPointerCppSideConnection cpp_side_connection;
-  RunTest("mojo/apps/js/test/js_to_cpp_unittest", &cpp_side_connection);
+  RunTest("mojo/edk/js/tests/js_to_cpp_tests", &cpp_side_connection);
   EXPECT_TRUE(cpp_side_connection.DidSucceed());
 }
 
diff --git a/mojo/apps/js/test/js_to_cpp_unittest.js b/mojo/edk/js/tests/js_to_cpp_tests.js
similarity index 97%
rename from mojo/apps/js/test/js_to_cpp_unittest.js
rename to mojo/edk/js/tests/js_to_cpp_tests.js
index 67313e7..c32f0af 100644
--- a/mojo/apps/js/test/js_to_cpp_unittest.js
+++ b/mojo/edk/js/tests/js_to_cpp_tests.js
@@ -2,9 +2,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-define('mojo/apps/js/test/js_to_cpp_unittest', [
+define('mojo/edk/js/tests/js_to_cpp_tests', [
   'console',
-  'mojo/apps/js/test/js_to_cpp.mojom',
+  'mojo/edk/js/tests/js_to_cpp.mojom',
   'mojo/public/js/connection',
   'mojo/public/js/connector',
   'mojo/public/js/core',
diff --git a/mojo/apps/js/bindings/sample_service_unittests.js b/mojo/edk/js/tests/sample_service_tests.js
similarity index 98%
rename from mojo/apps/js/bindings/sample_service_unittests.js
rename to mojo/edk/js/tests/sample_service_tests.js
index 8030f44..ca4f8e6 100644
--- a/mojo/apps/js/bindings/sample_service_unittests.js
+++ b/mojo/edk/js/tests/sample_service_tests.js
@@ -4,7 +4,7 @@
 
 define([
     "console",
-    "mojo/apps/js/test/hexdump",
+    "mojo/edk/js/test/hexdump",
     "gin/test/expect",
     "mojo/public/interfaces/bindings/tests/sample_service.mojom",
     "mojo/public/interfaces/bindings/tests/sample_import.mojom",
diff --git a/mojo/apps/js/bindings/threading.cc b/mojo/edk/js/threading.cc
similarity index 85%
rename from mojo/apps/js/bindings/threading.cc
rename to mojo/edk/js/threading.cc
index 6926437..b571e3e 100644
--- a/mojo/apps/js/bindings/threading.cc
+++ b/mojo/edk/js/threading.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "mojo/apps/js/bindings/threading.h"
+#include "mojo/edk/js/threading.h"
 
 #include "base/message_loop/message_loop.h"
 #include "gin/object_template_builder.h"
@@ -10,7 +10,7 @@
 #include "mojo/edk/js/handle.h"
 
 namespace mojo {
-namespace apps {
+namespace js {
 
 namespace {
 
@@ -22,7 +22,7 @@
 
 }  // namespace
 
-const char Threading::kModuleName[] = "mojo/apps/js/bindings/threading";
+const char Threading::kModuleName[] = "mojo/public/js/threading";
 
 v8::Local<v8::Value> Threading::GetModule(v8::Isolate* isolate) {
   gin::PerIsolateData* data = gin::PerIsolateData::From(isolate);
@@ -43,5 +43,5 @@
 Threading::Threading() {
 }
 
-}  // namespace apps
+}  // namespace js
 }  // namespace mojo
diff --git a/mojo/apps/js/bindings/threading.h b/mojo/edk/js/threading.h
similarity index 71%
rename from mojo/apps/js/bindings/threading.h
rename to mojo/edk/js/threading.h
index ac8e221..7cf0d53 100644
--- a/mojo/apps/js/bindings/threading.h
+++ b/mojo/edk/js/threading.h
@@ -2,14 +2,14 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_APPS_JS_BINDINGS_THREADING_H_
-#define MOJO_APPS_JS_BINDINGS_THREADING_H_
+#ifndef MOJO_EDK_JS_THREADING_H_
+#define MOJO_EDK_JS_THREADING_H_
 
 #include "gin/public/wrapper_info.h"
 #include "v8/include/v8.h"
 
 namespace mojo {
-namespace apps {
+namespace js {
 
 class Threading {
  public:
@@ -19,7 +19,7 @@
   Threading();
 };
 
-}  // namespace apps
+}  // namespace js
 }  // namespace mojo
 
-#endif  // MOJO_APPS_JS_BINDINGS_THREADING_H_
+#endif  // MOJO_EDK_JS_THREADING_H_
diff --git a/mojo/edk/js/waiting_callback.h b/mojo/edk/js/waiting_callback.h
index fdffde5..6b2ccc7 100644
--- a/mojo/edk/js/waiting_callback.h
+++ b/mojo/edk/js/waiting_callback.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_BINDINGS_JS_WAITING_CALLBACK_H_
-#define MOJO_BINDINGS_JS_WAITING_CALLBACK_H_
+#ifndef MOJO_EDK_JS_WAITING_CALLBACK_H_
+#define MOJO_EDK_JS_WAITING_CALLBACK_H_
 
 #include "gin/handle.h"
 #include "gin/runner.h"
@@ -60,4 +60,4 @@
 }  // namespace js
 }  // namespace mojo
 
-#endif  // MOJO_BINDINGS_JS_WAITING_CALLBACK_H_
+#endif  // MOJO_EDK_JS_WAITING_CALLBACK_H_
diff --git a/mojo/edk/mojo_edk.gyp b/mojo/edk/mojo_edk.gyp
index e826893..0a564a5 100644
--- a/mojo/edk/mojo_edk.gyp
+++ b/mojo/edk/mojo_edk.gyp
@@ -396,6 +396,8 @@
         'js/handle.cc',
         'js/handle.h',
         'js/handle_close_observer.h',
+        'js/threading.cc',
+        'js/threading.h',
         'js/support.cc',
         'js/support.h',
         'js/waiting_callback.cc',
@@ -411,7 +413,7 @@
         'mojo_common_test_support',
         'mojo_run_all_unittests',
         'mojo_js_lib',
-        '../public/mojo_public.gyp:mojo_environment_standalone',
+        '../public/mojo_public.gyp:mojo_environment_chromium',
         '../public/mojo_public.gyp:mojo_public_test_interfaces',
         '../public/mojo_public.gyp:mojo_utility',
       ],
diff --git a/mojo/public/js/threading.js b/mojo/public/js/threading.js
new file mode 100644
index 0000000..cfe5037
--- /dev/null
+++ b/mojo/public/js/threading.js
@@ -0,0 +1,21 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Module "mojo/public/js/threading"
+//
+// Note: This file is for documentation purposes only. The code here is not
+// actually executed. The real module is implemented natively in Mojo.
+//
+// This module provides a way for a Mojo application implemented in JS
+// to exit by quitting the current message loop. This module is not
+// intended to be used by Mojo JS application started by the JS
+// content handler.
+
+while (1);
+
+/**
+ * Quits the current message loop, esssentially:
+ * base::MessageLoop::current()->QuitNow();
+*/
+function quit() { [native code] }
diff --git a/mojo/tools/data/unittests b/mojo/tools/data/unittests
index f44e393..f8dc6ab 100644
--- a/mojo/tools/data/unittests
+++ b/mojo/tools/data/unittests
@@ -23,8 +23,8 @@
 view_manager_unittests
 
 # JavaScript tests:
-*apps_js_unittests
 *js_unittests
+*js_integration_tests
 
 # Shell integration tests:
 *mojo_shell_tests