LCOV - app.info - js/src/jsapi-tests/testDeepFreeze.cpp

LCOV - code coverage report
| Current view: | directory - js/src/jsapi-tests - testDeepFreeze.cpp (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 29 | 29 | 100.0 %
| Date: | 2012-04-07 | Functions: | 18 | 14 | 77.8 %

           1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
           2                 :  * vim: set ts=8 sw=4 et tw=99:
           3                 :  */
           4                 :
           5                 : #include "tests.h"
           6                 :
           7               4 : BEGIN_TEST(testDeepFreeze_bug535703)
           8                 : {
           9                 :     jsval v;
          10               1 :     EVAL("var x = {}; x;", &v);
          11               1 :     CHECK(JS_DeepFreezeObject(cx, JSVAL_TO_OBJECT(v)));  // don't crash
          12               1 :     EVAL("Object.isFrozen(x)", &v);
          13               1 :     CHECK_SAME(v, JSVAL_TRUE);
          14               1 :     return true;
          15                 : }
          16               1 : END_TEST(testDeepFreeze_bug535703)
          17                 :
          18               4 : BEGIN_TEST(testDeepFreeze_deep)
          19                 : {
          20                 :     jsval a, o;
          21               1 :     EXEC("var a = {}, o = a;\n"
          22                 :          "for (var i = 0; i < 5000; i++)\n"
          23                 :          "    a = {x: a, y: a};\n");
          24               1 :     EVAL("a", &a);
          25               1 :     EVAL("o", &o);
          26                 :
          27               1 :     CHECK(JS_DeepFreezeObject(cx, JSVAL_TO_OBJECT(a)));
          28                 :
          29                 :     jsval b;
          30               1 :     EVAL("Object.isFrozen(a)", &b);
          31               1 :     CHECK_SAME(b, JSVAL_TRUE);
          32               1 :     EVAL("Object.isFrozen(o)", &b);
          33               1 :     CHECK_SAME(b, JSVAL_TRUE);
          34               1 :     return true;
          35                 : }
          36               1 : END_TEST(testDeepFreeze_deep)
          37                 :
          38               4 : BEGIN_TEST(testDeepFreeze_loop)
          39                 : {
          40                 :     jsval x, y;
          41               1 :     EXEC("var x = [], y = {x: x}; y.y = y; x.push(x, y);");
          42               1 :     EVAL("x", &x);
          43               1 :     EVAL("y", &y);
          44                 :
          45               1 :     CHECK(JS_DeepFreezeObject(cx, JSVAL_TO_OBJECT(x)));
          46                 :
          47                 :     jsval b;
          48               1 :     EVAL("Object.isFrozen(x)", &b);
          49               1 :     CHECK_SAME(b, JSVAL_TRUE);
          50               1 :     EVAL("Object.isFrozen(y)", &b);
          51               1 :     CHECK_SAME(b, JSVAL_TRUE);
          52               1 :     return true;
          53                 : }
          54               3 : END_TEST(testDeepFreeze_loop)

Generated by: LCOV version 1.7