You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add polymer-resin API to enable migration and custom report handling.
YT would like to be able to use goog.log instead of the JS dev console.
The report handler API enables that, without pulling goog.log in for
the standalone compiled version.
In the getting-started docs, I need a story to explain how to get
telemetry about false positives.
When migrating an app, one might do
var polymerResinDebugTelemetry = {};
// Allow application to progress as normal so we can exercise
// as much of the API as possible without working around problems
// caused by false positives.
// HACK: DO NOT SUBMIT.
security.polymer_resin.UNSAFE_passThruDisallowedValues(true);
// Collect violation counts in a table instead of logging.
security.polymer_resin.setReportHandler(
function (isDisallowedValue, fmtString,
optContextNodeName, optNodeName, optAttrName, optValue,
var_args) {
if (isDisallowedValue) {
var key = optContextNodeName + ' : ' + optNodeName + ' : '
+ optAttrName;
polymerResingDebugTelemetry[key] =
(polymerResingDebugTelemetry[key] || 0) + 1;
}
});
// Can be called from console.
function dumpPolymerResinDebugTelemetry() {
console.log(JSON.stringify(polymerResinDebugTelemetry, null, 2));
}
The report handler API can also be used to feed violations during
production back to the server for later investigation.
Tested:
I have not added tests for the new APIs.
I ran existing test suite to test default behavior.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=157109206
goog.DEBUG&&"undefined"!==typeofconsole&&console.warn("Failed to sanitize text %o in %o",value,node.parentElement);
2971
+
security.polymer_resin.reportHandler_&&security.polymer_resin.reportHandler_(!0,"Failed to sanitize %s %s%s node to value %O",node.parentElement&&node.parentElement.nodeName,"#text","",value);
goog.DEBUG&&"undefined"!==typeofconsole&&console.warn('Failed to sanitize <%s %s="%o">',elementName,attrName,value);
3012
+
security.polymer_resin.reportHandler_&&security.polymer_resin.reportHandler_(!0,'Failed to sanitize in %s: <%s %s="%O">',elementName,elementName,attrName,value);
0 commit comments