Revision: 5577
Author: [email protected]
Date: Fri Aug 23 20:27:28 2013 UTC
Log: add ses-explicit to tests, and always capture some browser results
https://codereview.appspot.com/13171045
This adds ses/explicit.html to the list of tests run,
so we can gather a record of how browsers behave.
This also modifies browser capture (in a dumb/easy way)
so that some test runs will always be captured
whether they pass or fail.
R=kpreid2, markm
http://code.google.com/p/google-caja/source/detail?r=5577
Modified:
/trunk/src/com/google/caja/ses/explicit.html
/trunk/tests/com/google/caja/plugin/BrowserTestCase.java
/trunk/tests/com/google/caja/plugin/MainBrowserTest.java
/trunk/tests/com/google/caja/plugin/WebDriverHandle.java
/trunk/tests/com/google/caja/plugin/test-index.html
/trunk/tests/com/google/caja/ses/SESBrowserTest.java
/trunk/tests/com/google/caja/ses/ses-tests.json
=======================================
--- /trunk/src/com/google/caja/ses/explicit.html Sat Jul 13 15:35:24 2013
UTC
+++ /trunk/src/com/google/caja/ses/explicit.html Fri Aug 23 20:27:28 2013
UTC
@@ -36,6 +36,9 @@
<div id="scriptTest">scriptTest...</div>
<div id="amdLoaderTest">AMD loader test...</div>
+<!-- for communication with automated test driver -->
+<div id="testSignals" class="testcontainer"></div>
+
<script src="useHTMLLogger.js"></script>
<script>
function gebi(id) {
@@ -65,10 +68,25 @@
<script src="ejectorsGuardsTrademarks.js"></script>
<script src="hookupSESPlus.js"></script>
+<script>
+ var testSignals = gebi('testSignals');
+ var testExpected = 4;
+ var testPasses = 0;
+ testSignals.className += ' readytotest';
+ function testDone() {
+ "use strict";
+ if (testPasses === testExpected) {
+ document.title += ' - all tests passed';
+ }
+ testSignals.className += ' done';
+ }
+</script>
+
<script>
var amdLoaderTest = gebi('amdLoaderTest');
- function appendText(node, text) {
+ function appendResult(node, text) {
"use strict";
+ if (/^succeeded/.test(text)) { testPasses += 1; }
node.appendChild(document.createTextNode(text));
}
(function() {
@@ -77,10 +95,11 @@
var moduleTest = gebi('moduleTest');
var scriptTest = gebi('scriptTest');
if (!ses.ok()) {
- appendText(exprTest, 'cancelled');
- appendText(moduleTest, 'cancelled');
- appendText(scriptTest, 'cancelled');
- appendText(amdLoaderTest, 'cancelled');
+ appendResult(exprTest, 'cancelled');
+ appendResult(moduleTest, 'cancelled');
+ appendResult(scriptTest, 'cancelled');
+ appendResult(amdLoaderTest, 'cancelled');
+ testDone();
return;
}
@@ -92,7 +111,7 @@
var output = cajaVM.eval('3+4') *
cajaVM.compileExpr('window')(imports);
var text1 = output === 42 ? 'succeeded' : 'failed: ' + output;
- appendText(exprTest, text1);
+ appendResult(exprTest, text1);
// Test ability to bootstrap support for a limited form of
// CommonJS modules.
@@ -119,7 +138,7 @@
"returned": 77
}, void 0, ' ');
var text2 = did === should ? 'succeeded' : 'failed: ' + did;
- appendText(moduleTest, text2);
+ appendResult(moduleTest, text2);
// Tests the ability to do inter-module linkage as scripts
// traditionally did, by modification of (virtual) shared
@@ -128,7 +147,7 @@
cajaVM.compileModule('this.x = 88;')(imports);
var text3 = cajaVM.compileExpr('x')(imports) === 88 ?
'succeeded' : 'failed';
- appendText(scriptTest, text3);
+ appendResult(scriptTest, text3);
})();
</script>
@@ -210,9 +229,11 @@
Q(amdTestP).then(function(amdTest) {
var amdTestStatus = amdTest === 'this is a test' ?
'succeeded' : 'failed, unexpected: ' + amdTest;
- appendText(amdLoaderTest, amdTestStatus);
+ appendResult(amdLoaderTest, amdTestStatus);
+ testDone();
}, function(reason) {
- appendText(amdLoaderTest, 'failed: ' + reason);
+ appendResult(amdLoaderTest, 'failed: ' + reason);
+ testDone();
}).end();
})();
</script>
=======================================
--- /trunk/tests/com/google/caja/plugin/BrowserTestCase.java Fri Aug 9
20:06:48 2013 UTC
+++ /trunk/tests/com/google/caja/plugin/BrowserTestCase.java Fri Aug 23
20:27:28 2013 UTC
@@ -152,7 +152,7 @@
result = driveBrowser(driver);
passed = true;
} finally {
- wdh.captureResults(label, passed);
+ captureResults(label, passed);
wdh.end(passed || isKnownFailure);
}
} catch (Exception e) {
@@ -162,6 +162,21 @@
}
return result;
}
+
+ private void captureResults(String label, boolean passed) {
+ if (alwaysCapture(label)) {
+ wdh.captureResults("keep." + label);
+ } else if (!passed) {
+ wdh.captureResults("fail." + label);
+ } else if (TestFlag.CAPTURE_PASSES.truthy()) {
+ wdh.captureResults("pass." + label);
+ }
+ }
+
+ protected boolean alwaysCapture(String label) {
+ // TODO(felix8a): maybe this should be a flag in browser-tests.json
+ return false;
+ }
protected static String escapeUri(String s) {
StringBuilder sb = new StringBuilder();
=======================================
--- /trunk/tests/com/google/caja/plugin/MainBrowserTest.java Fri Aug 23
17:52:44 2013 UTC
+++ /trunk/tests/com/google/caja/plugin/MainBrowserTest.java Fri Aug 23
20:27:28 2013 UTC
@@ -41,4 +41,9 @@
return super.waitForCompletionTimeout();
}
}
+
+ @Override
+ protected boolean alwaysCapture(String label) {
+ return label.startsWith("guest-scan-");
+ }
}
=======================================
--- /trunk/tests/com/google/caja/plugin/WebDriverHandle.java Thu Aug 8
19:23:22 2013 UTC
+++ /trunk/tests/com/google/caja/plugin/WebDriverHandle.java Fri Aug 23
20:27:28 2013 UTC
@@ -199,16 +199,13 @@
}
}
- public void captureResults(String name, boolean passed) {
+ public void captureResults(String name) {
if (driver == null) { return; }
-
- if (passed && !TestFlag.CAPTURE_PASSES.truthy()) { return; }
String dir = TestFlag.CAPTURE_TO.getString("");
if ("".equals(dir)) { return; }
if (!dir.endsWith("/")) { dir = dir + "/"; }
- dir += passed ? "pass/" : "fail/";
mkdirs(dir);
// Try to capture the final html
=======================================
--- /trunk/tests/com/google/caja/plugin/test-index.html Thu Jul 11 22:50:37
2013 UTC
+++ /trunk/tests/com/google/caja/plugin/test-index.html Fri Aug 23 20:27:28
2013 UTC
@@ -58,11 +58,6 @@
<ul id='thirdparty' class='testlist'></ul>
<h2>Manual tools</h2>
<ul>
- <li><a href="../../../../../src/com/google/caja/ses/explicit.html">
- <!-- explicit.html is not copied into the test tree; doing so would
- also require its unconcatenated-SES *.js dependencies to be.
-->
- Detailed SES initialization report
- </a></li>
<li><a href="apidiff/analyzer.html">Browser API report/diff</a></li>
<li><a
href="browser-test-case.html?test-case=repl.html&es5=true">
REPL inside the sandbox</a></li>
=======================================
--- /trunk/tests/com/google/caja/ses/SESBrowserTest.java Tue May 14
21:13:11 2013 UTC
+++ /trunk/tests/com/google/caja/ses/SESBrowserTest.java Fri Aug 23
20:27:28 2013 UTC
@@ -27,4 +27,9 @@
@RunWith(CatalogRunner.class)
@CatalogRunner.CatalogName("ses-tests.json")
public class SESBrowserTest extends CatalogTestCase {
+
+ @Override
+ protected boolean alwaysCapture(String label) {
+ return label.equals("ses-explicit");
+ }
}
=======================================
--- /trunk/tests/com/google/caja/ses/ses-tests.json Mon Aug 19 22:19:02
2013 UTC
+++ /trunk/tests/com/google/caja/ses/ses-tests.json Fri Aug 23 20:27:28
2013 UTC
@@ -1,4 +1,12 @@
[
+ {
+ "label": "ses-explicit",
+ "bare": "../../../../../src/com/google/caja/ses/explicit.html",
+ "mode": "none",
+ "comment": [
+ "Detailed SES initialization report"
+ ]
+ },
{
"label": "ses-loading",
"bare": "../ses/test-ses-loading.html",
--
---
You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.