Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Commit

Permalink
fix up FetchResponse.arayBuffer() (woops)
Browse files Browse the repository at this point in the history
  • Loading branch information
alastaircoote committed Oct 16, 2017
1 parent e8ddc1b commit c3b7462
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ private var allowedCORSHeaders = [
}

func arrayBuffer() -> JSValue? {
NSLog("are we even hitting this?")

guard let ctx = JSContext.current() else {
Log.error?("Tried to call arrayBuffer() outside of a JSContext")
return nil
}

if self.responseType == .Opaque {

Expand All @@ -161,13 +167,7 @@ private var allowedCORSHeaders = [

return self.data()
.then { data -> JSValue? in

guard let currentContext = JSContext.current() else {
Log.error?("Tried to call arrayBuffer() outside of a JSContext")
return nil
}

let buffer = JSArrayBuffer.make(from: data, in: currentContext)
let buffer = JSArrayBuffer.make(from: data, in: ctx)
return buffer
}.toJSPromiseInCurrentContext()
}
Expand Down
2 changes: 1 addition & 1 deletion ServiceWorker/ServiceWorkerTests/Fetch/FetchResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class FetchResponseTests: XCTestCase {
fetch('\(TestWeb.serverURL.appendingPathComponent("/test.dat"))')
.then(function(res) { return res.arrayBuffer() })
.then(function(arrBuffer) {
let arr = new Uint8Array(arrBuffer);
let arr = new Uint8Array(arrBuffer);
return [arr[0],arr[1],arr[2],arr[3],arr[4]]
})
Expand Down

0 comments on commit c3b7462

Please sign in to comment.