Skip to content

Commit

Permalink
FAILING TEST (Le Sigh 😞 )
Browse files Browse the repository at this point in the history
  I have discussed this in the past with @domenic.
  He seems to think all requests/responses should default to
  `text/javascript`

  Unfortunately...ALL(?) browsers seem to request JS with
  `application/javascript`
  And in response servers respond with `application/javascript`

  In order to abide by his convention we need to update a myriad of
  libraries in Ruby AND Javascript for these tests to pass.

  Pros:
    Luckily most browsers and servers are "broken" therefore
    our "false positives" with `application/javascript` work. ¯\_(ツ)_/¯

  Cons:
    If only one extension related per mime there will be blood!
    Although `text/javascript` may be more correct...
    the web (as we know it) still uses `application/javascript`
    convention.

  See References:
    - #164

  Next steps:
    Determine if issue needs to be created in
    WHATWG HTML / DOM / Fetch ¯\_(ツ)_/¯
    This will be the only way we can get user land mime libraries
    updated without an IETF (pending) blessing for `text/javascript`.

  /cc @tmornini @brandondees
  • Loading branch information
snuggs committed Jun 11, 2018
1 parent 2e69a26 commit 2fa7d27
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
29 changes: 29 additions & 0 deletions resource/negotiate.test
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,35 @@ test ('Resource JS GET / Accept: application/javascript', async t => {
, modified = headers.get ('Last-Modified')


t.ok (modified)
t.equal ( status, 200 )
t.ok (type.match (accept))
t.ok (type.match (charset))
t.ok (length == expected.length)
t.equal ( expected, await response.text `` )

server.close ``
t.end ()
})


test ('Resource JS GET / Accept: text/javascript', async t => {

const
accept = 'text/javascript'
, charset = 'charset=utf-8'
, server = (new Server ([ middleware ])).serve ``
, expected = read (`resource/fixtures/index.js`)
, options = {
compress : false
, headers : { accept } }
, response = await fetch (URI, options)
, { status, headers } = response
, type = headers.get ('content-type')
, length = headers.get ('Content-Length')
, modified = headers.get ('Last-Modified')


t.ok (modified)
t.equal ( status, 200 )
t.ok (type.match (accept))
Expand Down
3 changes: 0 additions & 3 deletions server/index.test
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ test ('middleware collection dependency injection', async t => {

const
middleware = context =>
!!! console.warn ('WTF') &&
context.set ('test', 'Hello World')

, stack = [ middleware ]
Expand All @@ -71,8 +70,6 @@ test ('middleware collection dependency injection', async t => {
= await fetch (`http://localhost:${process.env.PORT}/`)


console.dir (headers)

t.equal
( headers.get ('test'), 'Hello World' )

Expand Down

0 comments on commit 2fa7d27

Please sign in to comment.