summaryrefslogtreecommitdiff
path: root/deps/v8/test/inspector/debugger/resource-name-to-url.js
blob: 620c7a2864b406539fc7fc0e4b5a89b06a0847f3 (plain)
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
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

let {session, contextGroup, Protocol} = InspectorTest.start(
  'Tests V8InspectorClient::resourceNameToUrl.');

(async function test(){
  Protocol.Runtime.enable();
  await Protocol.Debugger.enable();
  contextGroup.addScript(`inspector.setResourceNamePrefix('prefix://')`);
  await Protocol.Debugger.onceScriptParsed();

  InspectorTest.log('Check script with url:');
  contextGroup.addScript('function foo(){}', 0, 0, 'url');
  InspectorTest.logMessage(await Protocol.Debugger.onceScriptParsed());

  InspectorTest.log('Check script with sourceURL comment:');
  contextGroup.addScript('function foo(){} //# sourceURL=foo.js', 0, 0, 'url');
  InspectorTest.logMessage(await Protocol.Debugger.onceScriptParsed());

  InspectorTest.log('Check script failed to parse:');
  contextGroup.addScript('function foo(){', 0, 0, 'url');
  InspectorTest.logMessage(await Protocol.Debugger.onceScriptFailedToParse());

  InspectorTest.log('Check script failed to parse with sourceURL comment:');
  contextGroup.addScript('function foo(){ //# sourceURL=foo.js', 0, 0, 'url');
  InspectorTest.logMessage(await Protocol.Debugger.onceScriptFailedToParse());

  InspectorTest.log('Test runtime stack trace:');
  contextGroup.addScript(`
    function foo() {
      console.log(42);
    }
    eval('foo(); //# sourceURL=boo.js');
  `, 0, 0, 'url');
  InspectorTest.logMessage(await Protocol.Runtime.onceConsoleAPICalled());

  InspectorTest.log('Test debugger stack trace:');
  contextGroup.addScript(`
    function foo() {
      debugger;
    }
    eval('foo(); //# sourceURL=boo.js');
  `, 0, 0, 'url');
  const {params:{callFrames}} = await Protocol.Debugger.oncePaused();
  InspectorTest.logMessage(callFrames.map(frame => frame.url));
  InspectorTest.completeTest();
})();