     newPost: 'https://ask.metafilter.com/contribute/post.cfm'
     postPreview: 'post_preview.cfm'
     commentPreview: '/contribute/post_comment_preview.mefi#commentpreview'
-
-
+  fanFare:
+    hostname: 'fanfare.metafilter.com'
+    newPost: 'https://fanfare.metafilter.com/contribute/post.cfm'
+    postPreview:'post_preview.cfm'
+
+    # Path + hash
+    commentPreviewUrl: '/contribute/post_comment_preview.mefi#commentpreview'
+
+    commentPreviewPathname: '/contribute/post_comment_preview.mefi'
+    commentPreviewHash: '#commentpreview'
+
+    threadPathname: '/2212/Forever-Hitler-on-the-Half-Shell'
+    threadLinkId: 2122
+
+#simulateSave = (sessionStorage, site, for, mdCommentText, mdExtendedText) ->
+simulateSave = (options) ->
+  sessionStorage = options.sessionStorage ? throw new Error
+  site           = options.site           ? throw new Error
+  type           = options.type           ? throw new Error
+  mdCommentText  = options.mdCommentText  ? null
+  mdExtendedText = options.mdExtendedText ? null
+  if (type != 'comment' && type != 'post') 
+    throw new Error("Bad argument 'type': #{type}")
+
+  sr = saveRestore.makeSaveRestore
+    sessionStorage: options.sessionStorage
+    location: makeLocation
+      # Location of the comment thread
+      hostname: postUrls[site].hostname
+      pathname: postUrls[site].threadPathname
+
+  # Simulate clicking the preview button
+  sr.saveMarkdownForPreview
+    mdCommentText: mdCommentText
+    mdExtendedText: mdExtendedText
+    linkId: if (type == 'comment') then postUrls[site].threadLinkId else undefined
+    # The URL we're going to, that previews the comment/post
+    formSubmitUrl: 
+      if (type == 'comment') then postUrls[site].commentPreviewUrl else postUrls[site].postPreview
+
+simulateLoad = (options) ->
+  sessionStorage = options.sessionStorage ? throw new Error
+  site           = options.site           ? throw new Error
+  type           = options.type           ? throw new Error
+
+  # We have one location object for both this page and the page after submitting
+  # the preview form, since we're on a preview page. The preview page leads
+  # back to itself.
+  #
+  # TODO: But that won't be true for all the test cases
+  if (type == 'comment')
+    location = makeLocation
+      hostname: postUrls[site].hostname
+      pathname: postUrls[site].commentPreviewPathname 
+      hash:     postUrls[site].commentPreviewHash
+
+    linkId = postUrls[site].threadLinkId
+  else if (type == 'post')
+    location = makeLocation
+      hostname: postUrls[site].hostName
+      pathname: postUrls[site].postPreview
+
+    linkId = undefined
+  else
+    throw new Error("Bad argument 'type': #{type}")
+
+  # Load the markdown on the preview page
+  sr = saveRestore.makeSaveRestore
+    sessionStorage: sessionStorage
+    location: location
+
+  formSubmitUrl = location.pathname + location.hash
+
+  savedDataJson = sr.restoreMarkdown 
+    linkId: linkId
+    formSubmitUrl: formSubmitUrl
+
+  return {
+    storageKey: sr.getSessionStorageKey linkId, formSubmitUrl
+    savedDataJson: savedDataJson
+    sr: sr
+  }
 
 
 #doTestCase = require('../lib/test-utils').doTestCase


  test.done()



# Simulate doing one preview of a MeFi FPP

# Create a mock window.location, with
# sensible MeFi defaults.
makeLocation = (location) ->
  location ?= {}

  # Abort if we accidentally used a camelcase name.
  ['hostName', 'pathName'].forEach (key) ->
    if location.hasOwnProperty(key) 
      throw new Error("makeLocation: Invalid location key: #{key}")

  location['protocol'] ?= "https:"
  location['hostname'] ?= "www.metafilter.com"
  location['pathname'] ?= "/"
  if !/^\//.test(location['pathname'])
    throw new Error("makeLocation: pathname needs to start with a slash: " +
      location['pathname'])
  if /#/.test(location['pathname'])
    throw new Error("makeLocation: Get that hash out of the pathname")

  location['hash']     ?= ''
  if !/(^$)|^#/.test(location['hash'])
    throw new Error("makeLocation: Hash needs to be empty string or start with #: " +
      location['hash'])

  location['href']     ?= location.protocol + location.hostname + location.pathname
  return location

exports['test sessionStorage mock'] = (test) ->
