|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object junit.framework.Assert junit.framework.TestCase com.google.caja.util.CajaTestCase com.google.caja.parser.quasiliteral.RewriterTestCase com.google.caja.parser.quasiliteral.CommonJsRewriterTestCase com.google.caja.parser.quasiliteral.CajitaRewriterTest
public class CajitaRewriterTest
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.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 |
---|
protected Rewriter cajitaRewriter
Constructor Detail |
---|
public CajitaRewriterTest()
Method Detail |
---|
public void setUp() throws java.lang.Exception
setUp
in class CajaTestCase
java.lang.Exception
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)
private static java.lang.String weldReadPub(java.lang.String obj, java.lang.String varName, java.lang.String tempObj)
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 weldPreludes(java.lang.String... names)
private static java.lang.String weldPrelude(java.lang.String name)
private static java.lang.String weldPrelude(java.lang.String name, java.lang.String permitsUsed)
public final void testToString() throws java.lang.Exception
java.lang.Exception
public final void testInitializeMap() throws java.lang.Exception
java.lang.Exception
public final void testValueOf() throws java.lang.Exception
java.lang.Exception
public final void testFunctionDoesNotMaskVariable() throws java.lang.Exception
java.lang.Exception
public final void testAssertEqualsCajoled() throws java.lang.Exception
java.lang.Exception
public final void testAssertThrowsCajoledNoError() throws java.lang.Exception
java.lang.Exception
public final void testAssertThrowsCajoledErrorNoMsg() throws java.lang.Exception
java.lang.Exception
public final void testAssertThrowsCajoledErrorWithMsg() throws java.lang.Exception
java.lang.Exception
public final void testFreeVariables() throws java.lang.Exception
java.lang.Exception
public final void testConstructionWithFunction() throws java.lang.Exception
java.lang.Exception
public final void testReflectiveMethodInvocation() throws java.lang.Exception
java.lang.Exception
public final void testToxicBind() throws java.lang.Exception
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.
java.lang.Exception
public final void testBadDelete() throws java.lang.Exception
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.
java.lang.Exception
public final void testNameFuncExprScoping() throws java.lang.Exception
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.
java.lang.Exception
public final void testCajaPropsFrozen() throws java.lang.Exception
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.
java.lang.Exception
public final void testStringIndexing() throws java.lang.Exception
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.
java.lang.Exception
public final void testStringIndexing2() throws java.lang.Exception
java.lang.Exception
public final void testAttachedReflection() throws java.lang.Exception
Reading the apply property of a function should result in the apply method as attached to that function.
java.lang.Exception
public final void testInVeil() throws java.lang.Exception
The in operator should only test for properties visible to Caja.
java.lang.Exception
public final void testSyntheticIsUntouched() throws java.lang.Exception
java.lang.Exception
public final void testSyntheticMemberAccess() throws java.lang.Exception
java.lang.Exception
public final void testSyntheticNestedIsExpanded() throws java.lang.Exception
java.lang.Exception
public final void testSyntheticNestedFunctionIsExpanded() throws java.lang.Exception
java.lang.Exception
public final void testSyntheticFormals() throws java.lang.Exception
java.lang.Exception
public final void testNestedBlockWithFunction() throws java.lang.Exception
java.lang.Exception
public final void testNestedBlockWithVariable() throws java.lang.Exception
java.lang.Exception
public final void testWith() throws java.lang.Exception
java.lang.Exception
public final void testTryCatch() throws java.lang.Exception
java.lang.Exception
public final void testTryCatchFinally() throws java.lang.Exception
java.lang.Exception
public final void testTryFinally() throws java.lang.Exception
java.lang.Exception
public final void testVarArgs() throws java.lang.Exception
java.lang.Exception
public final void testVarThisBad() throws java.lang.Exception
java.lang.Exception
public final void testVarBadSuffix() throws java.lang.Exception
java.lang.Exception
public final void testVarBadSuffixDeclaration() throws java.lang.Exception
java.lang.Exception
public final void testVarFuncFreeze() throws java.lang.Exception
java.lang.Exception
public final void testVarGlobal() throws java.lang.Exception
java.lang.Exception
public final void testVarDefault() throws java.lang.Exception
java.lang.Exception
public final void testReadBadSuffix() throws java.lang.Exception
java.lang.Exception
public final void testReadBadPrototype() throws java.lang.Exception
java.lang.Exception
public final void testReadPublicLength() throws java.lang.Exception
java.lang.Exception
public final void testReadPublic() throws java.lang.Exception
java.lang.Exception
public final void testReadNumPublic() throws java.lang.Exception
java.lang.Exception
public final void testNumWithConstantIndex() throws java.lang.Exception
java.lang.Exception
public final void testReadIndexPublic() throws java.lang.Exception
java.lang.Exception
public final void testSetBadAssignToFunctionName() throws java.lang.Exception
java.lang.Exception
public final void testSetBadThis() throws java.lang.Exception
java.lang.Exception
public final void testSetBadFreeVariable() throws java.lang.Exception
java.lang.Exception
public final void testSetBadSuffix() throws java.lang.Exception
java.lang.Exception
public final void testSetBadPrototype() throws java.lang.Exception
java.lang.Exception
public final void testSetPublic() throws java.lang.Exception
java.lang.Exception
public final void testSetIndexPublic() throws java.lang.Exception
java.lang.Exception
public final void testSetBadInitialize() throws java.lang.Exception
java.lang.Exception
public final void testSetInitialize() throws java.lang.Exception
java.lang.Exception
public final void testSetBadDeclare() throws java.lang.Exception
java.lang.Exception
public final void testSetDeclare() throws java.lang.Exception
java.lang.Exception
public final void testSetVar() throws java.lang.Exception
java.lang.Exception
public final void testSetReadModifyWriteLocalVar() throws java.lang.Exception
java.lang.Exception
public final void testSetIncrDecr() throws java.lang.Exception
java.lang.Exception
public final void testSetIncrDecrOnLocals() throws java.lang.Exception
java.lang.Exception
public final void testSetIncrDecrOfComplexLValues() throws java.lang.Exception
java.lang.Exception
public final void testSetIncrDecrOrderOfAssignment() throws java.lang.Exception
java.lang.Exception
public final void testNewCallledCtor() throws java.lang.Exception
java.lang.Exception
public final void testNewCalllessCtor() throws java.lang.Exception
java.lang.Exception
public final void testDeletePub() throws java.lang.Exception
java.lang.Exception
public final void testDeleteFails() throws java.lang.Exception
java.lang.Exception
public final void testDeleteNonLvalue() throws java.lang.Exception
java.lang.Exception
public final void testCallPublic() throws java.lang.Exception
java.lang.Exception
public final void testCallIndexPublic() throws java.lang.Exception
java.lang.Exception
public final void testCallFunc() throws java.lang.Exception
java.lang.Exception
public final void testPermittedCall() throws java.lang.Exception
java.lang.Exception
public final void testFuncAnonSimple() throws java.lang.Exception
java.lang.Exception
public final void testFuncNamedSimpleDecl() throws java.lang.Exception
java.lang.Exception
public final void testFuncNamedSimpleValue() throws java.lang.Exception
java.lang.Exception
public final void testMaskingFunction() throws java.lang.Exception
java.lang.Exception
public final void testMapEmpty() throws java.lang.Exception
java.lang.Exception
public final void testMapBadKeySuffix() throws java.lang.Exception
java.lang.Exception
public final void testMapNonEmpty() throws java.lang.Exception
java.lang.Exception
public final void testMapSingle() throws java.lang.Exception
java.lang.Exception
public final void testMapPlural() throws java.lang.Exception
java.lang.Exception
public final void testOtherInstanceof() throws java.lang.Exception
java.lang.Exception
public final void testOtherTypeof() throws java.lang.Exception
java.lang.Exception
public final void testLabeledStatement() throws java.lang.Exception
java.lang.Exception
public final void testRegexLiteral() throws java.lang.Exception
java.lang.Exception
public final void testOtherSpecialOp() throws java.lang.Exception
java.lang.Exception
public final void testMultiDeclaration2() throws java.lang.Exception
java.lang.Exception
public final void testRecurseParseTreeNodeContainer()
public final void testRecurseArrayConstructor() throws java.lang.Exception
java.lang.Exception
public final void testRecurseBlock()
public final void testRecurseBreakStmt() throws java.lang.Exception
java.lang.Exception
public final void testRecurseCaseStmt() throws java.lang.Exception
java.lang.Exception
public final void testRecurseConditional() throws java.lang.Exception
java.lang.Exception
public final void testRecurseContinueStmt() throws java.lang.Exception
java.lang.Exception
public final void testRecurseDebuggerStmt() throws java.lang.Exception
java.lang.Exception
public final void testRecurseDefaultCaseStmt() throws java.lang.Exception
java.lang.Exception
public final void testRecurseExpressionStmt()
public final void testRecurseIdentifier()
public final void testRecurseLiteral() throws java.lang.Exception
java.lang.Exception
public final void testRecurseLoop() throws java.lang.Exception
java.lang.Exception
public final void testRecurseNoop() throws java.lang.Exception
java.lang.Exception
public final void testRecurseOperation() throws java.lang.Exception
java.lang.Exception
public final void testRecurseReturnStmt() throws java.lang.Exception
java.lang.Exception
public final void testRecurseSwitchStmt() throws java.lang.Exception
java.lang.Exception
public final void testRecurseThrowStmt() throws java.lang.Exception
java.lang.Exception
public final void testCantReadProto() throws java.lang.Exception
java.lang.Exception
public final void testSpecimenClickme() throws java.lang.Exception
java.lang.Exception
public final void testSpecimenListfriends() throws java.lang.Exception
java.lang.Exception
public final void testRecursionOnIE() throws java.lang.Exception
java.lang.Exception
public final void testAssertConsistent() throws java.lang.Exception
java.lang.Exception
public final void testIE_Emulation() throws java.lang.Exception
java.lang.Exception
public final void testWrapperAccess() throws java.lang.Exception
java.lang.Exception
public final void testFrozenArray() throws java.lang.Exception
java.lang.Exception
public final void testFrozenObject() throws java.lang.Exception
java.lang.Exception
public final void testStamp() throws java.lang.Exception
java.lang.Exception
public final void testForwardReference() throws java.lang.Exception
java.lang.Exception
public final void testReformedGenerics() throws java.lang.Exception
java.lang.Exception
public final void testIndexOf() throws java.lang.Exception
java.lang.Exception
public final void testCallback() throws java.lang.Exception
java.lang.Exception
public final void testTable() throws java.lang.Exception
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.
java.lang.Exception
public final void testFuncNaming() throws java.lang.Exception
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.
java.lang.Exception
public final void testRecordInheritance() throws java.lang.Exception
java.lang.Exception
public final void testNoPrototypicalImports() throws java.lang.Exception
java.lang.Exception
public final void testModule() throws java.lang.Exception
java.lang.Exception
public final void testErrorFreeze() throws java.lang.Exception
CommonJsRewriterTestCase.testErrorTaming()
}.
java.lang.Exception
public final void testUnderscore() throws java.lang.Exception
java.lang.Exception
public final void testObjectFreeze() throws java.lang.Exception
java.lang.Exception
public final void testNoPrivilegeEscalation() throws java.lang.Exception
The uncajoled branch of the tests below establish that a null does cause a privilege escalation for normal non-strict JavaScript.
java.lang.Exception
public final void testTamedXo4aOkOnNull() throws java.lang.Exception
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.
java.lang.Exception
public final void testJSONClass() throws java.lang.Exception
java.lang.Exception
public final void testNoCanSetInheritance() throws java.lang.Exception
See issue 1052.
java.lang.Exception
public final void testFeralTameBoundary() throws java.lang.Exception
java.lang.Exception
protected java.lang.Object executePlain(java.lang.String caja) throws java.io.IOException
RewriterTestCase
executePlain
in class RewriterTestCase
java.io.IOException
protected java.lang.Object rewriteAndExecute(java.lang.String pre, java.lang.String caja, java.lang.String post) throws java.io.IOException, ParseException
RewriterTestCase
rewriteAndExecute
in class RewriterTestCase
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.
java.io.IOException
ParseException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |