advanced-defaults.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. var t = require('assert')
  2. module.exports = ({advanced}) => {
  3. before(async () => {
  4. await advanced.bringToFront()
  5. })
  6. it('access to file URLs', async () => {
  7. t.strictEqual(
  8. await advanced.evaluate(() =>
  9. state.file
  10. ),
  11. true,
  12. 'state.file should be true'
  13. )
  14. })
  15. it('header detection', async () => {
  16. t.strictEqual(
  17. await advanced.evaluate(() =>
  18. state.header
  19. ),
  20. true,
  21. 'state.header should be true'
  22. )
  23. })
  24. it('csp option', async () => {
  25. t.strictEqual(
  26. await advanced.evaluate(() =>
  27. state.csp
  28. ),
  29. false,
  30. 'state.csp should be false'
  31. )
  32. })
  33. it('allowed origins', async () => {
  34. t.deepStrictEqual(
  35. await advanced.evaluate(() =>
  36. state.origins
  37. ),
  38. {
  39. 'file://': '\\.(?:markdown|mdown|mkdn|md|mkd|mdwn|mdtxt|mdtext|text)(?:#.*|\\?.*)?$'
  40. },
  41. 'state.origins should contain only the file:// origin'
  42. )
  43. t.deepStrictEqual(
  44. await advanced.evaluate(() =>
  45. state.origins
  46. ),
  47. await advanced.evaluate(() =>
  48. Array.from(document.querySelectorAll('.m-list li'))
  49. .reduce((obj, origin) => (
  50. obj[
  51. origin.querySelector('span:nth-of-type(1)').innerText.trim() +
  52. '://' +
  53. origin.querySelector('span:nth-of-type(2)').innerText.trim()
  54. ] = origin.querySelector('.m-textfield input').value,
  55. obj
  56. ), {})
  57. ),
  58. 'state.origins should be identical to dom origins'
  59. )
  60. })
  61. }