Hatena::Groupmoz-addon

Ci.nsIZIGOROu

2008-04-16先手と大人と将来

続 RestTestをOSXのXULRunnerで動かす

| 19:06 |  続 RestTestをOSXのXULRunnerで動かす - Ci.nsIZIGOROu を含むブックマーク はてなブックマーク -  続 RestTestをOSXのXULRunnerで動かす - Ci.nsIZIGOROu

RestTestをOSXのXULRunnerで動かす - Ci.nsIZIGOROu - Mozilla 拡張機能勉強会TODOと課していたアプリケーションの終了が出来ないですが、

<script type="application/x-javascript">
<![CDATA[
function quit(aForceQuit) {
  var appStartup = Components.classes['@mozilla.org/toolkit/app-startup;1'].getService(Components.interfaces.nsIAppStartup);

  // eAttemptQuit will try to close each XUL window, but the XUL window can cancel the quit
  // process if there is unsaved data. eForceQuit will quit no matter what.
  var quitSeverity = aForceQuit ? Components.interfaces.nsIAppStartup.eForceQuit : Components.interfaces.nsIAppStartup.eAttemptQuit;
  appStartup.quit(quitSeverity);
}
]]>
</script>

こんなんをまるっとtester.xulのどこかに入れて、

<hbox>
  <button label="Quit" oncommand="quit(true);"/>
</hbox>

とかやればOKです。

完成版のtester.xul

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="http-tester" title="RESTTest - HTTP Tester"
		xmlns:html="http://www.w3.org/1999/xhtml"
		xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
		onload="byId('url').focus();"
		onunload="return true;">
  <script type="application/x-javascript" src="chrome://resttest/content/requester.js"/>
  <script type="application/x-javascript">
	<![CDATA[
			 function quit(aForceQuit) {
			 var appStartup = Components.classes['@mozilla.org/toolkit/app-startup;1'].getService(Components.interfaces.nsIAppStartup);

// eAttemptQuit will try to close each XUL window, but the XUL window can cancel the quit
// process if there is unsaved data. eForceQuit will quit no matter what.
var quitSeverity = aForceQuit ? Components.interfaces.nsIAppStartup.eForceQuit : Components.interfaces.nsIAppStartup.eAttemptQuit;
appStartup.quit(quitSeverity);
}
	]]>
  </script>
  <!-- toolbox -->
  <vbox flex="1">
	<groupbox flex="1">
	  <caption id="uri text" label="Request" crop="end"/>
	  <hbox align="center">
		<label value="URL" />
		<textbox id="url" flex="1" type="autocomplete" autocompletesearch="history" value="http://" onkeypress="if (event.keyCode == 13) {sendRequest(); return false;}"/>
	  </hbox>
	  <hbox align="center">
		<label value="Method" control="method.input"/>
		<menulist id="method" editable="true" onkeypress="if (event.keyCode == 13) {sendRequest(); return false;}">
		  <menupopup>
			<menuitem label="GET"/>
			<menuitem label="HEAD"/>
			<menuitem label="POST"/>
			<menuitem label="PUT"/>
			<menuitem label="DELETE"/>
			<menuitem label="OPTIONS"/>
		  </menupopup>
		</menulist>
	  </hbox>
	  <hbox align="center">
		<label value="Headers"/>
		<textbox id="headers" rows="3" value="Content-Type: application/x-www-form-urlencoded" multiline="true" flex="15" type="text" />
	  </hbox>
	  <hbox align="center">
		<label value="POST/PUT data"/>
		<textbox id="data" rows="4" multiline="true" wrapAround="true" flex="15" type="text" />
	  </hbox>
	  <hbox align="right">
		<button id="button" label="Send" onclick="sendRequest()"/>
	  </hbox>
	</groupbox>
	<groupbox flex="1">
	  <caption id="uri text" label="Response" crop="end"/>

	  <hbox align="center">
		<label value="Response Status" />
		<label value="" id="status"/>
	  </hbox>
	  <hbox align="center">
		<label value="Response Headers"/>
		<textbox id="response_headers" rows="5" value="" multiline="true" flex="15" type="text"/>
	  </hbox>
	  <hbox align="center">
		<label value="Response Text" />
		<textbox id="response" rows="8" multiline="true" wrapAround="true" flex="15" type="text" />
	  </hbox>
	</groupbox>
  </vbox>
  <hbox>
	<button label="Quit" oncommand="quit(true);"/>
  </hbox>
</window>