Import Cobalt 2.13418
diff --git a/src/cobalt/browser/browser_module.cc b/src/cobalt/browser/browser_module.cc
index 4870df4..a6df61e 100644
--- a/src/cobalt/browser/browser_module.cc
+++ b/src/cobalt/browser/browser_module.cc
@@ -202,6 +202,8 @@
 }
 
 void BrowserModule::Navigate(const GURL& url) {
+  web_module_loaded_.Reset();
+
   // Always post this as a task in case this is being called from the WebModule.
   self_message_loop_->PostTask(
       FROM_HERE, base::Bind(&BrowserModule::NavigateInternal, weak_this_, url));
@@ -218,8 +220,6 @@
 void BrowserModule::NavigateInternal(const GURL& url) {
   DCHECK_EQ(MessageLoop::current(), self_message_loop_);
 
-  web_module_loaded_.Reset();
-
   // First try the registered handlers (e.g. for h5vcc://). If one of these
   // handles the URL, we don't use the web module.
   if (TryURLHandlers(url)) {
@@ -284,9 +284,11 @@
   web_module_loaded_.Signal();
 }
 
+#if defined(ENABLE_WEBDRIVER)
 bool BrowserModule::WaitForLoad(const base::TimeDelta& timeout) {
   return web_module_loaded_.TimedWait(timeout);
 }
+#endif
 
 #if defined(ENABLE_SCREENSHOT)
 void BrowserModule::RequestScreenshotToFile(const FilePath& path,
diff --git a/src/cobalt/browser/browser_module.h b/src/cobalt/browser/browser_module.h
index 1535261..669738a 100644
--- a/src/cobalt/browser/browser_module.h
+++ b/src/cobalt/browser/browser_module.h
@@ -127,10 +127,12 @@
   // Called when the WebModule's Window.onload event is fired.
   void OnLoad();
 
+#if defined(ENABLE_WEBDRIVER)
   // Wait for the onload event to be fired with the specified timeout. If the
   // webmodule is not currently loading the document, this will return
   // immediately.
   bool WaitForLoad(const base::TimeDelta& timeout);
+#endif
 
   // Glue function to deal with the production of the main render tree,
   // and will manage handing it off to the renderer.
diff --git a/src/cobalt/build/build.id b/src/cobalt/build/build.id
index 7a68bfa..a0e7819 100644
--- a/src/cobalt/build/build.id
+++ b/src/cobalt/build/build.id
@@ -1 +1 @@
-13391
\ No newline at end of file
+13418
\ No newline at end of file
diff --git a/src/cobalt/script/mozjs/mozjs_global_environment.cc b/src/cobalt/script/mozjs/mozjs_global_environment.cc
index 992716f..d7456fe 100644
--- a/src/cobalt/script/mozjs/mozjs_global_environment.cc
+++ b/src/cobalt/script/mozjs/mozjs_global_environment.cc
@@ -236,6 +236,58 @@
   return success;
 }
 
+bool MozjsGlobalEnvironment::EvaluateScript(
+    const scoped_refptr<SourceCode>& source_code,
+    const scoped_refptr<Wrappable>& owning_object,
+    base::optional<OpaqueHandleHolder::Reference>* out_opaque_handle) {
+  DCHECK(thread_checker_.CalledOnValidThread());
+  JSAutoRequest auto_request(context_);
+  JSAutoCompartment auto_compartment(context_, global_object_proxy_);
+  JSExceptionState* previous_exception_state = JS_SaveExceptionState(context_);
+  JS::RootedValue result_value(context_);
+  if (!EvaluateScriptInternal(source_code, &result_value)) {
+    return false;
+  }
+  if (out_opaque_handle) {
+    JS::RootedObject js_object(context_);
+    JS_ValueToObject(context_, result_value, js_object.address());
+    MozjsObjectHandleHolder mozjs_object_holder(js_object, context_,
+                                                wrapper_factory());
+    out_opaque_handle->emplace(owning_object.get(), mozjs_object_holder);
+  }
+  JS_RestoreExceptionState(context_, previous_exception_state);
+  return true;
+}
+
+bool MozjsGlobalEnvironment::EvaluateScriptInternal(
+    const scoped_refptr<SourceCode>& source_code,
+    JS::MutableHandleValue out_result) {
+  DCHECK(thread_checker_.CalledOnValidThread());
+  DCHECK(global_object_proxy_);
+  MozjsSourceCode* mozjs_source_code =
+      base::polymorphic_downcast<MozjsSourceCode*>(source_code.get());
+
+  const std::string& script = mozjs_source_code->source_utf8();
+  const base::SourceLocation location = mozjs_source_code->location();
+
+  JS::RootedObject global_object(
+      context_, js::GetProxyTargetObject(global_object_proxy_));
+
+  size_t length = script.size();
+  jschar* inflated_buffer =
+      js::InflateUTF8String(context_, script.c_str(), &length);
+  DCHECK(inflated_buffer);
+  bool success = false;
+  if (inflated_buffer) {
+    success = JS_EvaluateUCScript(context_, global_object, inflated_buffer,
+                                  length, location.file_path.c_str(),
+                                  location.line_number, out_result.address());
+    js_free(inflated_buffer);
+  }
+
+  return success;
+}
+
 std::vector<StackFrame> MozjsGlobalEnvironment::GetStackTrace(int max_frames) {
   DCHECK(thread_checker_.CalledOnValidThread());
   return util::GetStackTrace(context_, max_frames);
@@ -319,7 +371,7 @@
   if (global_object_proxy_ && garbage_collection_count_ == 1) {
     DCHECK(!opaque_root_state_);
     JSAutoRequest auto_request(context_);
-    JSAutoCompartment auto_comparment(context_, global_object_proxy_);
+    JSAutoCompartment auto_compartment(context_, global_object_proxy_);
     // Get the current state of opaque root relationships. Keep this object
     // alive for the duration of the GC phase to ensure that reachability
     // between roots and reachable objects is maintained.
diff --git a/src/cobalt/script/mozjs/mozjs_global_environment.h b/src/cobalt/script/mozjs/mozjs_global_environment.h
index 54f75de..d13d7f0 100644
--- a/src/cobalt/script/mozjs/mozjs_global_environment.h
+++ b/src/cobalt/script/mozjs/mozjs_global_environment.h
@@ -56,10 +56,7 @@
   bool EvaluateScript(const scoped_refptr<SourceCode>& script_utf8,
                       const scoped_refptr<Wrappable>& owning_object,
                       base::optional<OpaqueHandleHolder::Reference>*
-                          out_opaque_handle) OVERRIDE {
-    NOTIMPLEMENTED();
-    return false;
-  }
+                          out_opaque_handle) OVERRIDE;
 
   std::vector<StackFrame> GetStackTrace(int max_frames = 0) OVERRIDE;
 
@@ -133,7 +130,10 @@
   // with an error that eval() is disabled.
   static JSBool CheckEval(JSContext* context);
 
- protected:
+ private:
+  bool EvaluateScriptInternal(const scoped_refptr<SourceCode>& source_code,
+                              JS::MutableHandleValue out_result);
+
   static void ReportErrorHandler(JSContext* context, const char* message,
                                  JSErrorReport* report);