Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Set mimetype on eval scripts - Fix #59
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Jul 20, 2016
1 parent 16b3f31 commit 0196ecd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
13 changes: 8 additions & 5 deletions src/chrome/chromeDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {DebugProtocol} from 'vscode-debugprotocol';
import {StoppedEvent, InitializedEvent, TerminatedEvent, OutputEvent, Handles, Event} from 'vscode-debugadapter';

import {IDebugAdapter, ILaunchRequestArgs, ISetBreakpointsArgs, ISetBreakpointsResponseBody, IStackTraceResponseBody,
IAttachRequestArgs, IBreakpoint, IScopesResponseBody, IVariablesResponseBody,
IAttachRequestArgs, IScopesResponseBody, IVariablesResponseBody,
ISourceResponseBody, IThreadsResponseBody, IEvaluateResponseBody} from '../debugAdapterInterfaces';
import {ChromeConnection} from './chromeConnection';
import * as ChromeUtils from './chromeUtils';
Expand Down Expand Up @@ -408,7 +408,7 @@ export class ChromeDebugAdapter implements IDebugAdapter {
return Promise.all(responsePs);
}

private chromeBreakpointResponsesToODPBreakpoints(url: string, responses: Chrome.Debugger.SetBreakpointResponse[], requestLines: number[]): IBreakpoint[] {
private chromeBreakpointResponsesToODPBreakpoints(url: string, responses: Chrome.Debugger.SetBreakpointResponse[], requestLines: number[]): DebugProtocol.Breakpoint[] {
// Don't cache errored responses
const committedBpIds = responses
.filter(response => !response.error)
Expand All @@ -423,14 +423,14 @@ export class ChromeDebugAdapter implements IDebugAdapter {
// The output list needs to be the same length as the input list, so map errors to
// unverified breakpoints.
if (response.error || !response.result.actualLocation) {
return <IBreakpoint>{
return <DebugProtocol.Breakpoint>{
verified: false,
line: requestLines[i],
column: 0
};
}

return <IBreakpoint>{
return <DebugProtocol.Breakpoint>{
verified: true,
line: response.result.actualLocation.lineNumber,
column: response.result.actualLocation.columnNumber
Expand Down Expand Up @@ -597,7 +597,10 @@ export class ChromeDebugAdapter implements IDebugAdapter {

public source(args: DebugProtocol.SourceArguments): Promise<ISourceResponseBody> {
return this._chromeConnection.debugger_getScriptSource(sourceReferenceToScriptId(args.sourceReference)).then(chromeResponse => {
return { content: chromeResponse.result.scriptSource };
return {
content: chromeResponse.result.scriptSource,
mimeType: 'text/javascript'
};
});
}

Expand Down
7 changes: 2 additions & 5 deletions src/debugAdapterInterfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,17 @@ export interface ISetBreakpointsArgs extends DebugProtocol.SetBreakpointsArgumen
authoredPath?: string;
}

export interface IBreakpoint extends DebugProtocol.Breakpoint {
column?: number;
}

/*
* The ResponseBody interfaces are copied from debugProtocol.d.ts which defines these inline in the Response interfaces.
* They should always match those interfaces, see the original for comments.
*/
export interface ISetBreakpointsResponseBody {
breakpoints: IBreakpoint[];
breakpoints: DebugProtocol.Breakpoint[];
}

export interface ISourceResponseBody {
content: string;
mimeType?: string;
}

export interface IThreadsResponseBody {
Expand Down
4 changes: 2 additions & 2 deletions test/transformers/sourceMapTransformer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as mockery from 'mockery';
import {Mock, MockBehavior, It} from 'typemoq';

import {ISetBreakpointsResponseBody,
ILaunchRequestArgs, ISetBreakpointsArgs, IBreakpoint} from '../../src/debugAdapterInterfaces';
ILaunchRequestArgs, ISetBreakpointsArgs} from '../../src/debugAdapterInterfaces';
import * as testUtils from '../testUtils';
import {SourceMaps} from '../../src/sourceMaps/sourceMaps';
import {MappedPosition} from '../../src/sourceMaps/sourceMap';
Expand Down Expand Up @@ -180,7 +180,7 @@ suite('SourceMapTransformer', () => {
function getResponseBody(lines: number[], column?: number): ISetBreakpointsResponseBody {
return {
breakpoints: lines.map(line => {
const bp: IBreakpoint = { line, verified: true };
const bp: DebugProtocol.Breakpoint = { line, verified: true };
if (column !== undefined) {
bp.column = column;
}
Expand Down

0 comments on commit 0196ecd

Please sign in to comment.