ABC 2013 Spring で @dynamis さんにコマンド引数で指定できるはず、ということを聞いたので調べてみた。
手元の Mac だと
/Users/[username]/Library/Application Support/Firefox/Profiles/vr2npksq.default/extensions/r2d2b2g@mozilla.org/resources/r2d2b2g/data/content/js/main.js
が Firefox OS Simulator のダッシュボードの js で、window の postMessage() でフックしてます。
toggle: function() {
$(this.toggler).prop('indeterminate', true);
window.postMessage({ name: "toggle" }, "*");
},
実際に Simulator のプロセス(b2g-bin)を起動してるのが
/Users/[username]/Library/Application Support/Firefox/Profiles/vr2npksq.default/extensions/r2d2b2g@mozilla.org/resources/r2d2b2g/lib/remote-simulator-client.js
です。
...
// compute current b2g file handle
get b2gExecutable() {
if (this._executable) return this._executable;
let executables = {
WINNT: "win32/b2g/b2g-bin.exe",
Darwin: "mac64/B2G.app/Contents/MacOS/b2g-bin",
Linux: (Runtime.XPCOMABI.indexOf("x86_64") == 0 ? "linux64" : "linux") +
"/b2g/b2g-bin",
};
let url = Self.data.url(executables[Runtime.OS]);
let path = URL.toFilename(url);
let executable = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
executable.initWithPath(path);
let executableFilename = executables[Runtime.OS];
// Support B2G binaries built without GAIADIR.
if (!executable.exists()) {
let executables = {
WINNT: "win32/b2g/b2g.exe",
Darwin: "mac64/B2G.app/Contents/MacOS/b2g",
Linux: (Runtime.XPCOMABI.indexOf("x86_64") == 0 ? "linux64" : "linux") +
"/b2g/b2g",
};
let url = Self.data.url(executables[Runtime.OS]);
let path = URL.toFilename(url);
executable.initWithPath(path);
executableFilename = executables[Runtime.OS];
}
this._executable = executable;
this._executableFilename = executableFilename;
return executable;
},
// compute b2g CLI arguments
get b2gArguments() {
let args = [];
let profile = URL.toFilename(profileURL);
args.push("-profile", profile);
// NOTE: push dbgport option on the b2g-desktop commandline
args.push("-dbgport", ""+this.remoteDebuggerPort);
args.push("-pbport", ""+this.pingbackServerPort);
if (this.jsConsoleEnabled) {
args.push("-jsconsole");
}
//args.push("--screen=320x480@160");
//args.push("--screen=480x800@240");
//args.push("--screen=iphone");
//args.push("--screen=tattoo");
args.push("--screen=galaxy_nexus");
if (this._defaultApp != null) {
args.push("--runapp", this._defaultApp);
}
return args;
},
...
b2gArguments() がコマンドライン引数を設定しているところなので、
ここに
args.push("--screen=320x480@160");
とか追加すれば画面サイズを変えることができます。
注意:remote-simulator-client.js を変更したあと、Firefox を再起動する必要があります。
指定方法は
--screen=[width]x[height]@[resolution]
です。@[resolution]部分は省略できます。
ほかにもデバイス名で指定できるものもあって、https://developer.mozilla.org/ja/docs/Mozilla/Boot_to_Gecko/Using_the_B2G_desktop_client によると
- iphone
- ipad
- nexus_s
- galaxy_nexus
- galaxy_tab
- wildfire
- tattoo
- salsa
- chacha
HTC tattoo 持ってます。懐かしい。どこいったかな。。。
--screen=tattoo
レイアウト崩れます。。。


--screen=iphone
画面サイズを指定しない場合と同じっぽい

--screen=nexus_s
ホームボタンの部分が画面の途中にでて、ロック解除できません。。。

--screen=galaxy_nexus
nexus_s と同じような状態に。。。

ということで最初に指摘したとおり、全然使える状態ではありませんでした。。。
0 件のコメント:
コメントを投稿