2015. 6. 12.
@CSS魔法
history.state 的
为什么?
怎样……实现?
怎样……测试?
(30 ~ 45 分钟)
history.length 属性
history.go() 方法
history.back() 方法
history.forward() 方法
history.pushState(state, title, url) 方法
history.relaceState(state, title, url) 方法
window 的 "popstate" 事件
"popstate" 事件的 event.state 属性
history.state 属性
以下环境没有实现 history.state 属性:
history.state
(讨论)
在不需要打补丁的环境中,直接退出
在需要打补丁的环境中,模拟原生行为
在无法打补丁的环境中,向控制台报错后退出
history.pushState() 被调用时
history.relaceState() 被调用时
前进/后退时
“当 state 变化时手动更新 history.state 属性。”
state
("popstate" 事件触发时)
"popstate"
Mocha 测试框架
Chai 断言库
BDD 风格
“测试页面不能刷新!”
如何刷新沙盒?
如何得知沙盒已加载完成?
沙盒与宿主环境(测试页面)如何通信?
“如何重复调用并测试同一 API?”
我写的 history.state 的 Polyfill 项目
GitHub: cssmagic/history.state
cssmagic/history.state
$ npm install history.state
You'll need it, I bet.
// polyfill historyState.polyfill() // detection historyState.isSupported()
Thank you!
By CSS魔法
Repo: cssmagic/history.state