DXR will be turned off on Tuesday, December 29th. It will redirect to Searchfox.
See the announcement on Discourse.

DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c68fe15a81fc)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
<!DOCTYPE html>
<html>
<head>
  <script nonce="abc" src="/resources/testharness.js"></script>
  <script nonce="abc" src="/resources/testharnessreport.js"></script>
  <script nonce="abc" src="support/helper.sub.js"></script>

  <!-- Note: Trusted Types enforcement, and a CSP that allows all eval. -->
  <meta http-equiv="Content-Security-Policy"
        content="script-src 'nonce-abc' 'unsafe-eval'; require-trusted-types-for 'script'">
</head>
<body>
<script nonce="abc">
  let p = createScript_policy(window, 1);
  test(t => {
    let a = 0;
    assert_throws_js(EvalError, _ => {
      eval('a="hello there"');
    });
    assert_equals(a, 0);
  }, "eval with plain string with Trusted Types and permissive CSP throws (no type).");

  test(t => {
    let a = 0;
    assert_throws_js(EvalError, _ => {
      new Function('a="hello there"');
    });
    assert_equals(a, 0);
  }, "Function constructor with plain string with Trusted Types and permissive CSP throws (no type).");

  test(t => {
    let s = eval(p.createScript('"Hello transformed string"'));
    assert_equals("" + s, "Hello a cat string");
  }, "eval with TrustedScript and permissive CSP works.");

  test(t => {
    assert_throws_js(EvalError, _ => {
      // The Function constructor will string-ify its arguments. Hence, this
      // throw because no default policy is defined.
      let s = new Function(p.createScript('return "Hello transformed string"'));
    });
  }, "new Function with TrustedScript and permissive CSP works.");

  trustedTypes.createPolicy("default", { createScript: createScriptJS }, true);
  test(t => {
    let s = eval('"Hello transformed untrusted string"');
    assert_equals(s, "Hello a cat untrusted string");
  }, "eval with default policy and permissive CSP still obeys default policy.");

  test(t => {
    let s = new Function('return "Hello transformed untrusted string"')();
    assert_equals(s, "Hello a cat untrusted string");
  }, "new Function with default policy and permissive CSP still obeys default policy.");
</script>