tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

testErrorCopying.cpp (1175B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 * vim: set ts=8 sts=2 et sw=2 tw=80:
      3 *
      4 * Tests that the column number of error reports is properly copied over from
      5 * other reports when invoked from the C++ api.
      6 */
      7 /* This Source Code Form is subject to the terms of the Mozilla Public
      8 * License, v. 2.0. If a copy of the MPL was not distributed with this
      9 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     10 
     11 #include "js/CallAndConstruct.h"
     12 #include "js/Exception.h"
     13 #include "jsapi-tests/tests.h"
     14 
     15 BEGIN_TEST(testErrorCopying_columnCopied) {
     16  //    0        1         2
     17  //    1234567890123456789012345678
     18  EXEC("function check() { Object; foo; }");
     19 
     20  JS::RootedValue rval(cx);
     21  CHECK(!JS_CallFunctionName(cx, global, "check", JS::HandleValueArray::empty(),
     22                             &rval));
     23  JS::ExceptionStack exnStack(cx);
     24  CHECK(JS::StealPendingExceptionStack(cx, &exnStack));
     25 
     26  JS::ErrorReportBuilder report(cx);
     27  CHECK(report.init(cx, exnStack, JS::ErrorReportBuilder::WithSideEffects));
     28 
     29  CHECK_EQUAL(report.report()->column.oneOriginValue(), 28u);
     30  return true;
     31 }
     32 
     33 END_TEST(testErrorCopying_columnCopied)