com.google.caja.parser.quasiliteral
Class CajitaRewriterTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by com.google.caja.util.CajaTestCase
              extended by com.google.caja.parser.quasiliteral.RewriterTestCase
                  extended by com.google.caja.parser.quasiliteral.CommonJsRewriterTestCase
                      extended by com.google.caja.parser.quasiliteral.CajitaRewriterTest
All Implemented Interfaces:
junit.framework.Test

public class CajitaRewriterTest
extends CommonJsRewriterTestCase

Author:
ihab.awad@gmail.com, erights@gmail.com

Nested Class Summary
protected  class CajitaRewriterTest.TestUriFetcher
           
 
Field Summary
protected  Rewriter cajitaRewriter
           
 
Fields inherited from class com.google.caja.parser.quasiliteral.RewriterTestCase
rewriter
 
Fields inherited from class com.google.caja.util.CajaTestCase
is, mc, mq, SEED
 
Constructor Summary
CajitaRewriterTest()
           
 
Method Summary
protected  java.lang.Object executePlain(java.lang.String caja)
          Given some code, execute it without rewriting and return the value of the last expression in the code.
protected  java.lang.Object rewriteAndExecute(java.lang.String pre, java.lang.String caja, java.lang.String post)
          Given some code, rewrite it, then execute it in the proper context for the rewritten version and return the value of the last expression in the original code.
 void setUp()
           
 void testAssertConsistent()
           
 void testAssertEqualsCajoled()
           
 void testAssertThrowsCajoledErrorNoMsg()
           
 void testAssertThrowsCajoledErrorWithMsg()
           
 void testAssertThrowsCajoledNoError()
           
 void testAttachedReflection()
          Tests that bug#464 is fixed.
 void testBadDelete()
          Tests that bug#590 is fixed.
 void testCajaPropsFrozen()
          Tests that bug#469 is fixed.
 void testCallback()
           
 void testCallFunc()
           
 void testCallIndexPublic()
           
 void testCallPublic()
           
 void testCantReadProto()
           
 void testConstructionWithFunction()
           
 void testDeleteFails()
           
 void testDeleteNonLvalue()
           
 void testDeletePub()
           
 void testErrorFreeze()
          Tests that Error objects are frozen on being caught by a Cajita catch.
 void testFeralTameBoundary()
           
 void testForwardReference()
           
 void testFreeVariables()
           
 void testFrozenArray()
          Tests that Array.prototype cannot be modified.
 void testFrozenObject()
          Tests that Object.prototype cannot be modified.
 void testFuncAnonSimple()
           
 void testFuncNamedSimpleDecl()
           
 void testFuncNamedSimpleValue()
           
 void testFuncNaming()
          Although the golden output here tests many extraneous things, the point of this test is to see that various anonymous functions in the original are turned into named functions -- named after the variable or property they are initializing.
 void testFunctionDoesNotMaskVariable()
           
 void testIE_Emulation()
           
 void testIndexOf()
           
 void testInitializeMap()
           
 void testInVeil()
          Tests that bug#347 is fixed.
 void testJSONClass()
          Tests that the apparent [[Class]] of the tamed JSON object is 'JSON', as it should be according to ES5.
 void testLabeledStatement()
           
 void testMapBadKeySuffix()
           
 void testMapEmpty()
           
 void testMapNonEmpty()
           
 void testMapPlural()
           
 void testMapSingle()
           
 void testMaskingFunction()
           
 void testModule()
          Tests the static module loading
 void testMultiDeclaration2()
           
 void testNameFuncExprScoping()
          Tests that bug#617 is fixed.
 void testNestedBlockWithFunction()
           
 void testNestedBlockWithVariable()
           
 void testNewCallledCtor()
           
 void testNewCalllessCtor()
           
 void testNoCanSetInheritance()
          Tests that an inherited *_canSet___ fastpath flag does not enable bogus writability.
 void testNoPrivilegeEscalation()
          Tests that neither Cajita nor Valija code can cause a privilege escalation by calling a tamed exophoric function with null as the this-value.
 void testNoPrototypicalImports()
          Tests that properties that the global object inherits from Object.prototype are not readable as global variables.
 void testNumWithConstantIndex()
           
 void testObjectFreeze()
           
 void testOtherInstanceof()
           
 void testOtherSpecialOp()
           
 void testOtherTypeof()
           
 void testPermittedCall()
           
 void testReadBadPrototype()
           
 void testReadBadSuffix()
           
 void testReadIndexPublic()
           
 void testReadNumPublic()
           
 void testReadPublic()
           
 void testReadPublicLength()
           
 void testRecordInheritance()
           
 void testRecurseArrayConstructor()
           
 void testRecurseBlock()
           
 void testRecurseBreakStmt()
           
 void testRecurseCaseStmt()
           
 void testRecurseConditional()
           
 void testRecurseContinueStmt()
           
 void testRecurseDebuggerStmt()
           
 void testRecurseDefaultCaseStmt()
           
 void testRecurseExpressionStmt()
           
 void testRecurseIdentifier()
           
 void testRecurseLiteral()
           
 void testRecurseLoop()
           
 void testRecurseNoop()
           
 void testRecurseOperation()
           
 void testRecurseParseTreeNodeContainer()
           
 void testRecurseReturnStmt()
           
 void testRecurseSwitchStmt()
           
 void testRecurseThrowStmt()
           
 void testRecursionOnIE()
           
 void testReflectiveMethodInvocation()
           
 void testReformedGenerics()
           
 void testRegexLiteral()
           
 void testSetBadAssignToFunctionName()
           
 void testSetBadDeclare()
           
 void testSetBadFreeVariable()
           
 void testSetBadInitialize()
           
 void testSetBadPrototype()
           
 void testSetBadSuffix()
           
 void testSetBadThis()
           
 void testSetDeclare()
           
 void testSetIncrDecr()
           
 void testSetIncrDecrOfComplexLValues()
           
 void testSetIncrDecrOnLocals()
           
 void testSetIncrDecrOrderOfAssignment()
           
 void testSetIndexPublic()
           
 void testSetInitialize()
           
 void testSetPublic()
           
 void testSetReadModifyWriteLocalVar()
           
 void testSetVar()
           
 void testSpecimenClickme()
           
 void testSpecimenListfriends()
           
 void testStamp()
           
 void testStringIndexing()
          Tests that bug#292 is fixed.
 void testStringIndexing2()
           
 void testSyntheticFormals()
           
 void testSyntheticIsUntouched()
           
 void testSyntheticMemberAccess()
           
 void testSyntheticNestedFunctionIsExpanded()
           
 void testSyntheticNestedIsExpanded()
           
 void testTable()
          Tests the cajita.newTable(opt_useKeyLifetime) abstraction.
 void testTamedXo4aOkOnNull()
          Tests that the special handling of null on tamed exophora works.
 void testToString()
           
 void testToxicBind()
          Tests that bug#242 is fixed.
 void testTryCatch()
           
 void testTryCatchFinally()
           
 void testTryFinally()
           
 void testUnderscore()
           
 void testValueOf()
           
 void testVarArgs()
           
 void testVarBadSuffix()
           
 void testVarBadSuffixDeclaration()
           
 void testVarDefault()
           
 void testVarFuncFreeze()
           
 void testVarGlobal()
           
 void testVarThisBad()
           
 void testWith()
           
 void testWrapperAccess()
          Tests that the container can get access to "virtual globals" defined in cajoled code.
private static java.lang.String weldPrelude(java.lang.String name)
           
private static java.lang.String weldPrelude(java.lang.String name, java.lang.String permitsUsed)
           
private static java.lang.String weldPreludes(java.lang.String... names)
           
private static java.lang.String weldReadPub(java.lang.String obj, java.lang.String varName, java.lang.String tempObj)
          Welds together a string representing the repeated pattern of expected test output for reading an outer variable.
private static java.lang.String weldReadPub(java.lang.String obj, java.lang.String varName, java.lang.String tempObj, boolean flag)
           
private static java.lang.String weldSetPub(java.lang.String obj, java.lang.String varName, java.lang.String value, java.lang.String tempObj, java.lang.String tempValue)
          Welds together a string representing the repeated pattern of expected test output for assigning to an outer variable.
 
Methods inherited from class com.google.caja.parser.quasiliteral.CommonJsRewriterTestCase
testArrayLikeApply, testCatch, testCommonCallback, testCommonJSONClass, testCommonReformedGenerics, testConcatArguments, testCrossScopeArguments, testErrorTaming, testEval, testFor, testForIn1, testFunctionClass, testGetArgsCallee, testGetArgsCaller, testGetFuncArguments, testGetFuncCaller, testIn, testMultiDeclaration, testMutableArguments, testObjectWatch, testSameArguments, testSetArgsCallee, testSetArgsCaller, testSetFuncArguments, testSetFuncCaller, testSetTimeout, testStringLength, testTypeofConsistent
 
Methods inherited from class com.google.caja.parser.quasiliteral.RewriterTestCase
assertAddsMessage, assertConsistent, assertMessageNotPresent, assertMessageNotPresent, checkAddsMessage, checkAddsMessage, checkDoesNotAddMessage, checkFails, checkSucceeds, checkSucceeds, checkSucceeds, checkSucceeds, containsConsistentMessage, containsConsistentMessage, emulateIE6FunctionConstructors, getRewriter, makeSynthetic, rewriteAndExecute, rewriteTopLevelNode, setRewriter, syntheticTree
 
Methods inherited from class com.google.caja.util.CajaTestCase
assertArrayEquals, assertCloneable, assertDeepEquals, assertMessage, assertMessage, assertMessagesLessSevereThan, assertNoErrors, assertNoMessage, assertNoWarnings, checkHeadless, css, css, cssDecls, cssDecls, dataFromResource, formatShort, fromResource, fromResource, fromString, fromString, fromString, html, htmlFragment, js, js, js, jsExpr, jsExpr, markup, markupFragment, minify, plain, quasi, render, render, renderProgram, runTest, tearDown, xml, xmlFragment
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cajitaRewriter

protected Rewriter cajitaRewriter
Constructor Detail

CajitaRewriterTest

public CajitaRewriterTest()
Method Detail

setUp

public void setUp()
           throws java.lang.Exception
Overrides:
setUp in class CajaTestCase
Throws:
java.lang.Exception

weldSetPub

private static java.lang.String weldSetPub(java.lang.String obj,
                                           java.lang.String varName,
                                           java.lang.String value,
                                           java.lang.String tempObj,
                                           java.lang.String tempValue)
Welds together a string representing the repeated pattern of expected test output for assigning to an outer variable.


weldReadPub

private static java.lang.String weldReadPub(java.lang.String obj,
                                            java.lang.String varName,
                                            java.lang.String tempObj)
Welds together a string representing the repeated pattern of expected test output for reading an outer variable.


weldReadPub

private static java.lang.String weldReadPub(java.lang.String obj,
                                            java.lang.String varName,
                                            java.lang.String tempObj,
                                            boolean flag)

weldPreludes

private static java.lang.String weldPreludes(java.lang.String... names)

weldPrelude

private static java.lang.String weldPrelude(java.lang.String name)

weldPrelude

private static java.lang.String weldPrelude(java.lang.String name,
                                            java.lang.String permitsUsed)

testToString

public final void testToString()
                        throws java.lang.Exception
Throws:
java.lang.Exception

testInitializeMap

public final void testInitializeMap()
                             throws java.lang.Exception
Throws:
java.lang.Exception

testValueOf

public final void testValueOf()
                       throws java.lang.Exception
Throws:
java.lang.Exception

testFunctionDoesNotMaskVariable

public final void testFunctionDoesNotMaskVariable()
                                           throws java.lang.Exception
Throws:
java.lang.Exception

testAssertEqualsCajoled

public final void testAssertEqualsCajoled()
                                   throws java.lang.Exception
Throws:
java.lang.Exception

testAssertThrowsCajoledNoError

public final void testAssertThrowsCajoledNoError()
                                          throws java.lang.Exception
Throws:
java.lang.Exception

testAssertThrowsCajoledErrorNoMsg

public final void testAssertThrowsCajoledErrorNoMsg()
                                             throws java.lang.Exception
Throws:
java.lang.Exception

testAssertThrowsCajoledErrorWithMsg

public final void testAssertThrowsCajoledErrorWithMsg()
                                               throws java.lang.Exception
Throws:
java.lang.Exception

testFreeVariables

public final void testFreeVariables()
                             throws java.lang.Exception
Throws:
java.lang.Exception

testConstructionWithFunction

public final void testConstructionWithFunction()
                                        throws java.lang.Exception
Throws:
java.lang.Exception

testReflectiveMethodInvocation

public final void testReflectiveMethodInvocation()
                                          throws java.lang.Exception
Throws:
java.lang.Exception

testToxicBind

public final void testToxicBind()
                         throws java.lang.Exception
Tests that bug#242 is fixed.

The actual Function.bind() method used to be whitelisted and written to return a frozen simple-function, allowing it to be called from all code on all functions. As a result, if an outer hull breach occurs -- if Caja code obtains a reference to a JavaScript function value not marked as Caja-callable -- then that Caja code could call the whitelisted bind() on it, and then call the result, causing an inner hull breach which threatens kernel integrity.

Throws:
java.lang.Exception

testBadDelete

public final void testBadDelete()
                         throws java.lang.Exception
Tests that bug#590 is fixed.

As a client of an object, Caja code must only be able to directly delete public properties of non-frozen JSON containers. Due to this bug, Caja code was able to delete protected properties of non-frozen JSON containers.

Throws:
java.lang.Exception

testNameFuncExprScoping

public final void testNameFuncExprScoping()
                                   throws java.lang.Exception
Tests that bug#617 is fixed.

The ES3 spec specifies an insane scoping rule which Firefox 2.0.0.15 "correctly" implements according to the spec. The rule is that, within a named function expression, the function name f is brought into scope by creating a new object "as if by executing 'new Object()', adding an 'f' property to this object, and adding this object to the scope chain. As a result, all properties inherited from Object.prototype shadow any outer lexically visible declarations of those names as variable names.

Unfortunately, we're currently doing our JUnit testing using Rhino, which doesn't engage in the questionable behavior of implementing specified but insane behavior. As a result, the following test currently succeeds whether this bug is fixed or not.

Throws:
java.lang.Exception

testCajaPropsFrozen

public final void testCajaPropsFrozen()
                               throws java.lang.Exception
Tests that bug#469 is fixed.

The members of the caja object available to Caja code (i.e., the safeCaja object) must be frozen. And if they are functions, they should be marked as simple-functions. Before this bug was fixed, cajita.js failed to do either.

Throws:
java.lang.Exception

testStringIndexing

public final void testStringIndexing()
                              throws java.lang.Exception
Tests that bug#292 is fixed.

In anticipation of ES5, we should be able to index into strings using indexes which are numbers or stringified numbers, so long as they are in range.

Throws:
java.lang.Exception

testStringIndexing2

public final void testStringIndexing2()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testAttachedReflection

public final void testAttachedReflection()
                                  throws java.lang.Exception
Tests that bug#464 is fixed.

Reading the apply property of a function should result in the apply method as attached to that function.

Throws:
java.lang.Exception

testInVeil

public final void testInVeil()
                      throws java.lang.Exception
Tests that bug#347 is fixed.

The in operator should only test for properties visible to Caja.

Throws:
java.lang.Exception

testSyntheticIsUntouched

public final void testSyntheticIsUntouched()
                                    throws java.lang.Exception
Throws:
java.lang.Exception

testSyntheticMemberAccess

public final void testSyntheticMemberAccess()
                                     throws java.lang.Exception
Throws:
java.lang.Exception

testSyntheticNestedIsExpanded

public final void testSyntheticNestedIsExpanded()
                                         throws java.lang.Exception
Throws:
java.lang.Exception

testSyntheticNestedFunctionIsExpanded

public final void testSyntheticNestedFunctionIsExpanded()
                                                 throws java.lang.Exception
Throws:
java.lang.Exception

testSyntheticFormals

public final void testSyntheticFormals()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testNestedBlockWithFunction

public final void testNestedBlockWithFunction()
                                       throws java.lang.Exception
Throws:
java.lang.Exception

testNestedBlockWithVariable

public final void testNestedBlockWithVariable()
                                       throws java.lang.Exception
Throws:
java.lang.Exception

testWith

public final void testWith()
                    throws java.lang.Exception
Throws:
java.lang.Exception

testTryCatch

public final void testTryCatch()
                        throws java.lang.Exception
Throws:
java.lang.Exception

testTryCatchFinally

public final void testTryCatchFinally()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testTryFinally

public final void testTryFinally()
                          throws java.lang.Exception
Throws:
java.lang.Exception

testVarArgs

public final void testVarArgs()
                       throws java.lang.Exception
Throws:
java.lang.Exception

testVarThisBad

public final void testVarThisBad()
                          throws java.lang.Exception
Throws:
java.lang.Exception

testVarBadSuffix

public final void testVarBadSuffix()
                            throws java.lang.Exception
Throws:
java.lang.Exception

testVarBadSuffixDeclaration

public final void testVarBadSuffixDeclaration()
                                       throws java.lang.Exception
Throws:
java.lang.Exception

testVarFuncFreeze

public final void testVarFuncFreeze()
                             throws java.lang.Exception
Throws:
java.lang.Exception

testVarGlobal

public final void testVarGlobal()
                         throws java.lang.Exception
Throws:
java.lang.Exception

testVarDefault

public final void testVarDefault()
                          throws java.lang.Exception
Throws:
java.lang.Exception

testReadBadSuffix

public final void testReadBadSuffix()
                             throws java.lang.Exception
Throws:
java.lang.Exception

testReadBadPrototype

public final void testReadBadPrototype()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testReadPublicLength

public final void testReadPublicLength()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testReadPublic

public final void testReadPublic()
                          throws java.lang.Exception
Throws:
java.lang.Exception

testReadNumPublic

public final void testReadNumPublic()
                             throws java.lang.Exception
Throws:
java.lang.Exception

testNumWithConstantIndex

public final void testNumWithConstantIndex()
                                    throws java.lang.Exception
Throws:
java.lang.Exception

testReadIndexPublic

public final void testReadIndexPublic()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testSetBadAssignToFunctionName

public final void testSetBadAssignToFunctionName()
                                          throws java.lang.Exception
Throws:
java.lang.Exception

testSetBadThis

public final void testSetBadThis()
                          throws java.lang.Exception
Throws:
java.lang.Exception

testSetBadFreeVariable

public final void testSetBadFreeVariable()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

testSetBadSuffix

public final void testSetBadSuffix()
                            throws java.lang.Exception
Throws:
java.lang.Exception

testSetBadPrototype

public final void testSetBadPrototype()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testSetPublic

public final void testSetPublic()
                         throws java.lang.Exception
Throws:
java.lang.Exception

testSetIndexPublic

public final void testSetIndexPublic()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testSetBadInitialize

public final void testSetBadInitialize()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testSetInitialize

public final void testSetInitialize()
                             throws java.lang.Exception
Throws:
java.lang.Exception

testSetBadDeclare

public final void testSetBadDeclare()
                             throws java.lang.Exception
Throws:
java.lang.Exception

testSetDeclare

public final void testSetDeclare()
                          throws java.lang.Exception
Throws:
java.lang.Exception

testSetVar

public final void testSetVar()
                      throws java.lang.Exception
Throws:
java.lang.Exception

testSetReadModifyWriteLocalVar

public final void testSetReadModifyWriteLocalVar()
                                          throws java.lang.Exception
Throws:
java.lang.Exception

testSetIncrDecr

public final void testSetIncrDecr()
                           throws java.lang.Exception
Throws:
java.lang.Exception

testSetIncrDecrOnLocals

public final void testSetIncrDecrOnLocals()
                                   throws java.lang.Exception
Throws:
java.lang.Exception

testSetIncrDecrOfComplexLValues

public final void testSetIncrDecrOfComplexLValues()
                                           throws java.lang.Exception
Throws:
java.lang.Exception

testSetIncrDecrOrderOfAssignment

public final void testSetIncrDecrOrderOfAssignment()
                                            throws java.lang.Exception
Throws:
java.lang.Exception

testNewCallledCtor

public final void testNewCallledCtor()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testNewCalllessCtor

public final void testNewCalllessCtor()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testDeletePub

public final void testDeletePub()
                         throws java.lang.Exception
Throws:
java.lang.Exception

testDeleteFails

public final void testDeleteFails()
                           throws java.lang.Exception
Throws:
java.lang.Exception

testDeleteNonLvalue

public final void testDeleteNonLvalue()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testCallPublic

public final void testCallPublic()
                          throws java.lang.Exception
Throws:
java.lang.Exception

testCallIndexPublic

public final void testCallIndexPublic()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testCallFunc

public final void testCallFunc()
                        throws java.lang.Exception
Throws:
java.lang.Exception

testPermittedCall

public final void testPermittedCall()
                             throws java.lang.Exception
Throws:
java.lang.Exception

testFuncAnonSimple

public final void testFuncAnonSimple()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testFuncNamedSimpleDecl

public final void testFuncNamedSimpleDecl()
                                   throws java.lang.Exception
Throws:
java.lang.Exception

testFuncNamedSimpleValue

public final void testFuncNamedSimpleValue()
                                    throws java.lang.Exception
Throws:
java.lang.Exception

testMaskingFunction

public final void testMaskingFunction()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testMapEmpty

public final void testMapEmpty()
                        throws java.lang.Exception
Throws:
java.lang.Exception

testMapBadKeySuffix

public final void testMapBadKeySuffix()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testMapNonEmpty

public final void testMapNonEmpty()
                           throws java.lang.Exception
Throws:
java.lang.Exception

testMapSingle

public final void testMapSingle()
                         throws java.lang.Exception
Throws:
java.lang.Exception

testMapPlural

public final void testMapPlural()
                         throws java.lang.Exception
Throws:
java.lang.Exception

testOtherInstanceof

public final void testOtherInstanceof()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testOtherTypeof

public final void testOtherTypeof()
                           throws java.lang.Exception
Throws:
java.lang.Exception

testLabeledStatement

public final void testLabeledStatement()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testRegexLiteral

public final void testRegexLiteral()
                            throws java.lang.Exception
Throws:
java.lang.Exception

testOtherSpecialOp

public final void testOtherSpecialOp()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testMultiDeclaration2

public final void testMultiDeclaration2()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

testRecurseParseTreeNodeContainer

public final void testRecurseParseTreeNodeContainer()

testRecurseArrayConstructor

public final void testRecurseArrayConstructor()
                                       throws java.lang.Exception
Throws:
java.lang.Exception

testRecurseBlock

public final void testRecurseBlock()

testRecurseBreakStmt

public final void testRecurseBreakStmt()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testRecurseCaseStmt

public final void testRecurseCaseStmt()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testRecurseConditional

public final void testRecurseConditional()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

testRecurseContinueStmt

public final void testRecurseContinueStmt()
                                   throws java.lang.Exception
Throws:
java.lang.Exception

testRecurseDebuggerStmt

public final void testRecurseDebuggerStmt()
                                   throws java.lang.Exception
Throws:
java.lang.Exception

testRecurseDefaultCaseStmt

public final void testRecurseDefaultCaseStmt()
                                      throws java.lang.Exception
Throws:
java.lang.Exception

testRecurseExpressionStmt

public final void testRecurseExpressionStmt()

testRecurseIdentifier

public final void testRecurseIdentifier()

testRecurseLiteral

public final void testRecurseLiteral()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testRecurseLoop

public final void testRecurseLoop()
                           throws java.lang.Exception
Throws:
java.lang.Exception

testRecurseNoop

public final void testRecurseNoop()
                           throws java.lang.Exception
Throws:
java.lang.Exception

testRecurseOperation

public final void testRecurseOperation()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testRecurseReturnStmt

public final void testRecurseReturnStmt()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

testRecurseSwitchStmt

public final void testRecurseSwitchStmt()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

testRecurseThrowStmt

public final void testRecurseThrowStmt()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testCantReadProto

public final void testCantReadProto()
                             throws java.lang.Exception
Throws:
java.lang.Exception

testSpecimenClickme

public final void testSpecimenClickme()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testSpecimenListfriends

public final void testSpecimenListfriends()
                                   throws java.lang.Exception
Throws:
java.lang.Exception

testRecursionOnIE

public final void testRecursionOnIE()
                             throws java.lang.Exception
Throws:
java.lang.Exception

testAssertConsistent

public final void testAssertConsistent()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testIE_Emulation

public final void testIE_Emulation()
                            throws java.lang.Exception
Throws:
java.lang.Exception

testWrapperAccess

public final void testWrapperAccess()
                             throws java.lang.Exception
Tests that the container can get access to "virtual globals" defined in cajoled code.

Throws:
java.lang.Exception

testFrozenArray

public final void testFrozenArray()
                           throws java.lang.Exception
Tests that Array.prototype cannot be modified.

Throws:
java.lang.Exception

testFrozenObject

public final void testFrozenObject()
                            throws java.lang.Exception
Tests that Object.prototype cannot be modified.

Throws:
java.lang.Exception

testStamp

public final void testStamp()
                     throws java.lang.Exception
Throws:
java.lang.Exception

testForwardReference

public final void testForwardReference()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testReformedGenerics

public final void testReformedGenerics()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testIndexOf

public final void testIndexOf()
                       throws java.lang.Exception
Throws:
java.lang.Exception

testCallback

public final void testCallback()
                        throws java.lang.Exception
Throws:
java.lang.Exception

testTable

public final void testTable()
                     throws java.lang.Exception
Tests the cajita.newTable(opt_useKeyLifetime) abstraction.

From here, we are not in a position to test the weak-GC properties this abstraction is designed to provide, nor its O(1) complexity measure. However, we can test that it works as a simple lookup table.

Throws:
java.lang.Exception

testFuncNaming

public final void testFuncNaming()
                          throws java.lang.Exception
Although the golden output here tests many extraneous things, the point of this test is to see that various anonymous functions in the original are turned into named functions -- named after the variable or property they are initializing.

The test is structured as as a call stack resulting in a breakpoint. If executed, for example, in the testbed applet with Firebug enabled, one should see the stack of generated function names.

Throws:
java.lang.Exception

testRecordInheritance

public final void testRecordInheritance()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

testNoPrototypicalImports

public final void testNoPrototypicalImports()
                                     throws java.lang.Exception
Tests that properties that the global object inherits from Object.prototype are not readable as global variables.

Throws:
java.lang.Exception

testModule

public final void testModule()
                      throws java.lang.Exception
Tests the static module loading

Throws:
java.lang.Exception

testErrorFreeze

public final void testErrorFreeze()
                           throws java.lang.Exception
Tests that Error objects are frozen on being caught by a Cajita catch. See issue 1097, issue 1038, and CommonJsRewriterTestCase.testErrorTaming()}.

Throws:
java.lang.Exception

testUnderscore

public final void testUnderscore()
                          throws java.lang.Exception
Throws:
java.lang.Exception

testObjectFreeze

public final void testObjectFreeze()
                            throws java.lang.Exception
Throws:
java.lang.Exception

testNoPrivilegeEscalation

public final void testNoPrivilegeEscalation()
                                     throws java.lang.Exception
Tests that neither Cajita nor Valija code can cause a privilege escalation by calling a tamed exophoric function with null as the this-value.

The uncajoled branch of the tests below establish that a null does cause a privilege escalation for normal non-strict JavaScript.

Throws:
java.lang.Exception

testTamedXo4aOkOnNull

public final void testTamedXo4aOkOnNull()
                                 throws java.lang.Exception
Tests that the special handling of null on tamed exophora works.

The reification of tamed exophoric functions contains special cases for when the first argument to call, bind, or apply is null or undefined, in order to protect against privilege escalation. #testNoPrivilegeEscalation() tests that we do prevent the privilege escalation. Here, we test that this special case preserves correct functionality.

Throws:
java.lang.Exception

testJSONClass

public final void testJSONClass()
                         throws java.lang.Exception
Tests that the apparent [[Class]] of the tamed JSON object is 'JSON', as it should be according to ES5. See issue 1086

Throws:
java.lang.Exception

testNoCanSetInheritance

public final void testNoCanSetInheritance()
                                   throws java.lang.Exception
Tests that an inherited *_canSet___ fastpath flag does not enable bogus writability.

See issue 1052.

Throws:
java.lang.Exception

testFeralTameBoundary

public final void testFeralTameBoundary()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

executePlain

protected java.lang.Object executePlain(java.lang.String caja)
                                 throws java.io.IOException
Description copied from class: RewriterTestCase
Given some code, execute it without rewriting and return the value of the last expression in the code.

Specified by:
executePlain in class RewriterTestCase
Throws:
java.io.IOException

rewriteAndExecute

protected java.lang.Object rewriteAndExecute(java.lang.String pre,
                                             java.lang.String caja,
                                             java.lang.String post)
                                      throws java.io.IOException,
                                             ParseException
Description copied from class: RewriterTestCase
Given some code, rewrite it, then execute it in the proper context for the rewritten version and return the value of the last expression in the original code.

Specified by:
rewriteAndExecute in class RewriterTestCase
Parameters:
pre - a prefix program fragment to be executed plain.
caja - a program fragment to be rewritten.
post - a postfix program fragment to be executed plain.
Throws:
java.io.IOException
ParseException


Copyright (C) 2008 Google Inc.
Licensed under the Apache License, Version 2.0