Finally it's possible to write JS based WML layout tests. I now feel confident to integrate the WML variable substitution, as it can be tested reliable. Uploading patch soon.
Created attachment 25724 [details] Layout Tests
Created attachment 25725 [details] Initial patch
Landed in r38974.