Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
36 lines
1.1 KiB
JavaScript
Executable file
36 lines
1.1 KiB
JavaScript
Executable file
/* global Sanitizer */
|
|
|
|
'use strict';
|
|
|
|
require('/shared/js/sanitizer.js');
|
|
|
|
suite('tagged template helper', function() {
|
|
|
|
test('#escapeHTML', function() {
|
|
var myVal = '<b>hello</b>';
|
|
var generated = Sanitizer.escapeHTML `${myVal} world`;
|
|
assert.equal(generated, '<b>hello</b> world');
|
|
});
|
|
|
|
test('#createSafeHTML', function() {
|
|
var t = 'Click me';
|
|
var url = '" ><script>alert(1)</script>';
|
|
var s;
|
|
s = Sanitizer.createSafeHTML`<a href="${url}" title="${t}">${t}</a>`;
|
|
|
|
var expectedDocs = 'https://developer.mozilla.org/en-US/Firefox_OS/'+
|
|
'Security/Security_Automation';
|
|
assert.equal(s.__html,
|
|
'<a href="" ><script>alert(1)</script'+
|
|
'>" title="Click me">Click me</a>');
|
|
assert.ok(s.info.indexOf(expectedDocs) !== -1);
|
|
});
|
|
|
|
test('#unwrapSafeHTML', function() {
|
|
var escapeMe = '<s>hax</s>';
|
|
var obj = Sanitizer.createSafeHTML`<b>${escapeMe}</b>`;
|
|
var unwrapped = Sanitizer.unwrapSafeHTML(obj);
|
|
assert.equal(unwrapped, '<b><s>hax</s></b>');
|
|
});
|
|
|
|
});
|