Import Cobalt 16.154703
diff --git a/src/v8/test/debugger/debug/debug-evaluate-arguments.js b/src/v8/test/debugger/debug/debug-evaluate-arguments.js
new file mode 100644
index 0000000..8cf18d7
--- /dev/null
+++ b/src/v8/test/debugger/debug/debug-evaluate-arguments.js
@@ -0,0 +1,60 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax
+
+Debug = debug.Debug;
+var listened = false;
+
+function listener(event, exec_state, event_data, data) {
+  if (event != Debug.DebugEvent.Break) return;
+  try {
+    var foo_arguments = exec_state.frame(1).evaluate("arguments").value();
+    var bar_arguments = exec_state.frame(0).evaluate("arguments").value();
+    assertArrayEquals(foo_expected, foo_arguments);
+    assertArrayEquals(bar_expected, bar_arguments);
+    listened = true;
+  } catch (e) {
+    print(e);
+    print(e.stack);
+  }
+}
+
+Debug.setListener(listener);
+
+function foo(a) {
+  function bar(a,b,c) {
+    debugger;
+    return a + b + c;
+  }
+  return bar(1,2,a);
+}
+
+listened = false;
+foo_expected = [3];
+bar_expected = [1,2,3];
+assertEquals(6, foo(3));
+assertTrue(listened);
+
+listened = false;
+foo_expected = [3];
+bar_expected = [1,2,3];
+assertEquals(6, foo(3));
+assertTrue(listened);
+
+listened = false;
+foo_expected = [3];
+bar_expected = [1,2,3];
+%OptimizeFunctionOnNextCall(foo);
+assertEquals(6, foo(3));
+assertTrue(listened);
+
+listened = false;
+foo_expected = [3,4,5];
+bar_expected = [1,2,3];
+%OptimizeFunctionOnNextCall(foo);
+assertEquals(6, foo(3,4,5));
+assertTrue(listened);
+
+Debug.setListener(null);
diff --git a/src/v8/test/debugger/debug/debug-modules-set-variable-value.js b/src/v8/test/debugger/debug/debug-modules-set-variable-value.js
index 61c032f..1d1c6d5 100644
--- a/src/v8/test/debugger/debug/debug-modules-set-variable-value.js
+++ b/src/v8/test/debugger/debug/debug-modules-set-variable-value.js
@@ -271,7 +271,7 @@
   function listener(event, exec_state) {
     if (event == Debug.DebugEvent.Break) {
       let scope_count = exec_state.frame().scopeCount();
-      let module_scope = exec_state.frame().scope(2);
+      let module_scope = exec_state.frame().scope(1);
       assertEquals(debug.ScopeType.Module, module_scope.scopeType());
       module_scope.setVariableValue('salad', 42);
     }
@@ -311,7 +311,7 @@
   function listener(event, exec_state) {
     if (event == Debug.DebugEvent.Break) {
       let scope_count = exec_state.frame().scopeCount();
-      let module_scope = exec_state.frame().scope(2);
+      let module_scope = exec_state.frame().scope(1);
       assertEquals(debug.ScopeType.Module, module_scope.scopeType());
       module_scope.setVariableValue('ham', 2);
     }
diff --git a/src/v8/test/debugger/debug/debug-script.js b/src/v8/test/debugger/debug/debug-script.js
index 98aa555..342f619 100644
--- a/src/v8/test/debugger/debug/debug-script.js
+++ b/src/v8/test/debugger/debug/debug-script.js
@@ -28,10 +28,11 @@
 // Flags: --expose-gc --send-idle-notification
 // Flags: --expose-natives-as natives
 // Flags: --noharmony-shipping
-// Flags: --nostress-opt
+// Flags: --nostress-opt --nostress-background-compile
 
-// --nostress-opt is specified because in stress mode the compilation cache
-// may hold on to old copies of scripts (see bug 1641).
+// --nostress-opt and --nostress-background-compilation is specified because in
+// stress mode the compilation cache may hold on to old copies of scripts (see
+// bug 1641).
 
 // Note: this test checks that that the number of scripts reported as native
 // by Debug.scripts() is the same as a number of core native scripts.
diff --git a/src/v8/test/debugger/debug/harmony/modules-debug-scopes2.js b/src/v8/test/debugger/debug/harmony/modules-debug-scopes2.js
index 8b9b9e8..cc1091e 100644
--- a/src/v8/test/debugger/debug/harmony/modules-debug-scopes2.js
+++ b/src/v8/test/debugger/debug/harmony/modules-debug-scopes2.js
@@ -139,10 +139,10 @@
                    debug.ScopeType.Script,
                    debug.ScopeType.Global], exec_state);
   CheckScopeContent(
-      {local_var: undefined, exported_var: undefined, imported_var: undefined},
+      {exported_var: undefined, imported_var: undefined},
       0, exec_state);
   CheckScopeDoesNotHave(
-      ["doesnotexist", "local_let", "exported_let", "imported_let"],
+      ["local_var", "doesntexist", "local_let", "exported_let", "imported_let"],
       0, exec_state);
 };
 debugger;
@@ -161,8 +161,9 @@
                    debug.ScopeType.Script,
                    debug.ScopeType.Global], exec_state);
   CheckScopeContent(
-      {local_let: 1, local_var: 2, exported_let: 3, exported_var: 4,
+      {exported_let: 3, exported_var: 4,
        imported_let: 3, imported_var: 4}, 0, exec_state);
+  CheckScopeDoesNotHave(["local_var", "local_let"], 0, exec_state);
 };
 debugger;
 EndTest();
@@ -178,8 +179,9 @@
                    debug.ScopeType.Script,
                    debug.ScopeType.Global], exec_state);
   CheckScopeContent(
-      {local_let: 11, local_var: 12, exported_let: 13, exported_var: 14,
+      {exported_let: 13, exported_var: 14,
        imported_let: 13, imported_var: 14}, 0, exec_state);
+  CheckScopeDoesNotHave(["local_var", "local_let"], 0, exec_state);
 };
 debugger;
 EndTest();
diff --git a/src/v8/test/debugger/debug/regress/regress-1853.js b/src/v8/test/debugger/debug/regress/regress-1853.js
index 8c6e940..4cd069f 100644
--- a/src/v8/test/debugger/debug/regress/regress-1853.js
+++ b/src/v8/test/debugger/debug/regress/regress-1853.js
@@ -25,10 +25,11 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-
+// Flags: --expose-gc
 // Test whether scripts compiled after setting the break point are
 // updated correctly.
 
+gc();
 Debug = debug.Debug;
 
 var break_count = 0;
diff --git a/src/v8/test/debugger/debug/regress/regress-crbug-481896.js b/src/v8/test/debugger/debug/regress/regress-crbug-481896.js
index d123980..751b62a 100644
--- a/src/v8/test/debugger/debug/regress/regress-crbug-481896.js
+++ b/src/v8/test/debugger/debug/regress/regress-crbug-481896.js
@@ -1,8 +1,8 @@
 // Copyright 2015 the V8 project authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
-
-
+// Flags: --expose-gc
+gc();
 function static() {
   print("> static");  // Break
 }
diff --git a/src/v8/test/debugger/debug/regress/regress-crbug-517592.js b/src/v8/test/debugger/debug/regress/regress-crbug-517592.js
index e4a905d..57e96a2 100644
--- a/src/v8/test/debugger/debug/regress/regress-crbug-517592.js
+++ b/src/v8/test/debugger/debug/regress/regress-crbug-517592.js
@@ -4,7 +4,7 @@
 
 var source =
   "var foo = function foo() {\n" +
-  "  return 1;\n" +
+  "  var a = 1;\n" +
   "}\n" +
   "//@ sourceURL=test";
 
diff --git a/src/v8/test/debugger/debugger.status b/src/v8/test/debugger/debugger.status
index bbb4507..98a95eb 100644
--- a/src/v8/test/debugger/debugger.status
+++ b/src/v8/test/debugger/debugger.status
@@ -44,6 +44,12 @@
 }],  # variant == stress
 
 ##############################################################################
+['variant == stress_incremental_marking', {
+  # BUG(chromium:772010).
+  'debug/debug-*': [PASS, ['system == windows', SKIP]],
+}],  # variant == stress_incremental_marking
+
+##############################################################################
 ['gc_stress == True', {
   # Skip tests not suitable for GC stress.
   # Tests taking too long
diff --git a/src/v8/test/debugger/testcfg.py b/src/v8/test/debugger/testcfg.py
index a07acbc..e287077 100644
--- a/src/v8/test/debugger/testcfg.py
+++ b/src/v8/test/debugger/testcfg.py
@@ -9,14 +9,9 @@
 from testrunner.objects import testcase
 
 FILES_PATTERN = re.compile(r"//\s+Files:(.*)")
-FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
 MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE)
 
-class DebuggerTestSuite(testsuite.TestSuite):
-
-  def __init__(self, name, root):
-    super(DebuggerTestSuite, self).__init__(name, root)
-
+class TestSuite(testsuite.TestSuite):
   def ListTests(self, context):
     tests = []
     for dirname, dirs, files in os.walk(self.root):
@@ -29,17 +24,23 @@
           fullpath = os.path.join(dirname, filename)
           relpath = fullpath[len(self.root) + 1 : -3]
           testname = relpath.replace(os.path.sep, "/")
-          test = testcase.TestCase(self, testname)
+          test = self._create_test(testname)
           tests.append(test)
     return tests
 
-  def GetFlagsForTestCase(self, testcase, context):
-    source = self.GetSourceForTest(testcase)
-    flags = ["--enable-inspector", "--allow-natives-syntax"] + context.mode_flags
-    flags_match = re.findall(FLAGS_PATTERN, source)
-    for match in flags_match:
-      flags += match.strip().split()
+  def _test_class(self):
+    return TestCase
 
+
+class TestCase(testcase.TestCase):
+  def __init__(self, *args, **kwargs):
+    super(TestCase, self).__init__(*args, **kwargs)
+
+    source = self.get_source()
+    self._source_files = self._parse_source_files(source)
+    self._source_flags = self._parse_source_flags(source)
+
+  def _parse_source_files(self, source):
     files_list = []  # List of file names to append to command arguments.
     files_match = FILES_PATTERN.search(source);
     # Accept several lines of 'Files:'.
@@ -51,25 +52,31 @@
         break
 
     files = []
-    files.append(os.path.normpath(os.path.join(self.root, "..", "mjsunit", "mjsunit.js")))
-    files.append(os.path.join(self.root, "test-api.js"))
-    files.extend([ os.path.normpath(os.path.join(self.root, '..', '..', f))
-                  for f in files_list ])
+    files.append(os.path.normpath(os.path.join(
+        self.suite.root, "..", "mjsunit", "mjsunit.js")))
+    files.append(os.path.join(self.suite.root, "test-api.js"))
+    files.extend([os.path.normpath(os.path.join(self.suite.root, '..', '..', f))
+                  for f in files_list])
     if MODULE_PATTERN.search(source):
       files.append("--module")
-    files.append(os.path.join(self.root, testcase.path + self.suffix()))
+    files.append(os.path.join(self.suite.root, self.path + self._get_suffix()))
+    return files
 
-    flags += files
-    if context.isolates:
-      flags.append("--isolate")
-      flags += files
+  def _get_files_params(self, ctx):
+    files = self._source_files
+    if ctx.isolates:
+      files = files + ['--isolate'] + files
+    return files
 
-    return testcase.flags + flags
+  def _get_source_flags(self):
+    return self._source_flags
 
-  def GetSourceForTest(self, testcase):
-    filename = os.path.join(self.root, testcase.path + self.suffix())
-    with open(filename) as f:
-      return f.read()
+  def _get_suite_flags(self, ctx):
+    return ['--enable-inspector', '--allow-natives-syntax']
+
+  def _get_source_path(self):
+    return os.path.join(self.suite.root, self.path + self._get_suffix())
+
 
 def GetSuite(name, root):
-  return DebuggerTestSuite(name, root)
+  return TestSuite(name, root)