private byte[] askBytes(String optionalValue) {

		AtomicReference<byte[]> ref = new AtomicReference<>();
		runSwing(() -> {
			try {
				byte[] b = script.askBytes("Ask Test", "Enter bytes:");
				ref.set(b);
			}
			catch (Exception e) {
				failWithException("Exception was caught in this test: " + e.getMessage(), e);
			}
		}, false);

		AskDialog<?> askDialog = waitForDialogComponent(AskDialog.class);
		assertNotNull(askDialog);

		if (optionalValue != null) {
			String name = "JTextField";
			JTextField textField = (JTextField) findComponentByName(askDialog, name);
			setText(textField, optionalValue);
			waitForSwing();
		}

		pressButtonByText(askDialog, "OK");
		waitForSwing();

		return ref.get();
	}
A large timeout period that is usually not reached
Ghidra/Features/Base/src/test.slow/java/ghidra/app/script/GhidraScriptAskMethodsTest.java