Пример #1
0
void ExecutionContext::dispatchErrorEvent(ErrorEvent* errorEvent,
                                          AccessControlStatus corsStatus) {
  if (m_inDispatchErrorEvent) {
    m_pendingExceptions.append(errorEvent);
    return;
  }

  // First report the original exception and only then all the nested ones.
  if (!dispatchErrorEventInternal(errorEvent, corsStatus))
    exceptionThrown(errorEvent);

  if (m_pendingExceptions.isEmpty())
    return;
  for (ErrorEvent* e : m_pendingExceptions)
    exceptionThrown(e);
  m_pendingExceptions.clear();
}
Пример #2
0
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
, m_editor(0)
, m_hooqPlayInjector(new PlatformInjector(this))
, m_hooqRecordInjector(new PlatformInjector(this))
, m_hooqLogger(0)
, m_hooqPlayer(0)
, m_interpreter(new Interpreter(this))
, m_server(new QTcpServer(this))
, m_testModel(new TestModel(this))
, m_testRunning(false)
, m_testResultsWindow(new TestResultsDialog(this))
, m_xmlDump(0)
{
	if(!m_interpreter->haveRequiredQtScriptExtensions())
	{
		QMessageBox::critical(0, tr("Couldn't load required QtScript extensions"), tr("Please install qtscriptgenerator for the version of Qt you are currently using. While recording in Hooq may work, playback will not be possible."));
	}

	if(!m_server->listen(QHostAddress::LocalHost, Hooq::Communication::serverPort()))
	{
		QMessageBox::critical(0, tr("Couldn't listen for applications"), tr("Hooq couldn't start listening for applications; you're probably running two copies of Hooq. Hooq will not work."));
	}

	m_editor = new ScriptEditor(m_interpreter->engine());
	setupUi(this);
	setStatusBar(0);

	populateTestSets();

	m_testList->setModel(m_testModel);
	PushButtonDelegate* delegate = new PushButtonDelegate(m_testList, this);
	delegate->addButton(1, QApplication::style()->standardIcon(QStyle::SP_MediaPlay));
	delegate->addButton(2, QApplication::style()->standardIcon(QStyle::SP_FileIcon));
	m_testList->setItemDelegate(delegate);

	m_testList->header()->setResizeMode(0, QHeaderView::Stretch);
	m_testList->header()->setResizeMode(1, QHeaderView::Fixed);
	m_testList->header()->setResizeMode(2, QHeaderView::Fixed);
	m_testList->header()->setStretchLastSection(false);

	m_contextMenu = new QMenu(this);
	m_contextMenu->addAction(tr("Run"), this, SLOT(runCurrentTest()));
	m_contextMenu->addAction(tr("Edit"), this, SLOT(editCurrentTest()));
	m_contextMenu->addSeparator();
	m_contextMenu->addAction(tr("Delete"), this, SLOT(deleteCurrentTest()));

	setTestSet(m_testSetEdit->currentText());

	m_testList->setContextMenuPolicy(Qt::CustomContextMenu);

	QObject* deleteObserver = new ModelIndexKeyEventObserver(QKeySequence::Delete, m_testList);

	connect(
		deleteObserver,
		SIGNAL(released(QModelIndex)),
		SLOT(deleteCurrentTest())
	);

	connect(
		m_testList,
		SIGNAL(customContextMenuRequested(QPoint)),
		SLOT(showTestContextMenu(QPoint))
	);

	connect(
		m_testSetEdit,
		SIGNAL(activated(QString)),
		SLOT(setTestSet(QString))
	);

	connect(
		m_runAllButton,
		SIGNAL(clicked()),
		SLOT(runAllTests())
	);

	connect(
		m_addTestButton,
		SIGNAL(clicked()),
		SLOT(startRecording())
	);

	connect(
		m_hooqRecordInjector,
		SIGNAL(finished(int)),
		SLOT(finishRecording())
	);

	connect(
		m_testNameEdit,
		SIGNAL(textChanged(QString)),
		SLOT(updateActionStates())
	);

	connect(
		m_addTestSetButton,
		SIGNAL(clicked()),
		SLOT(addTestSet())
	);

	connect(
		m_newTestSet,
		SIGNAL(triggered()),
		SLOT(addTestSet())
	);
	connect(
		m_editTestSet,
		SIGNAL(triggered()),
		SLOT(editTestSet())
	);
	connect(
		m_removeTestSet,
		SIGNAL(triggered()),
		SLOT(removeTestSet())
	);
	connect(
		m_exportSet,
		SIGNAL(triggered()),
		SLOT(exportCurrentSet())
	);
	connect(
		m_importSet,
		SIGNAL(triggered()),
		SLOT(importTestSet())
	);
	connect(
		m_editor,
		SIGNAL(pickRequested()),
		m_interpreter,
		SLOT(pickObject())
	);
	connect(
		m_editor,
		SIGNAL(startRequested()),
		SLOT(runEditorTest())
	);

	connect(
		m_editor,
		SIGNAL(exceptionThrown(QString, QStringList)),
		SLOT(logException(QString, QStringList))
	);

	connect(
		m_interpreter,
		SIGNAL(objectPicked(ObjectInformation)),
		m_editor,
		SLOT(objectPicked(ObjectInformation))
	);
	connect(
		m_interpreter,
		SIGNAL(objectNotFound(QString)),
		m_editor,
		SLOT(objectNotFound(QString))
	);
	connect(
		m_interpreter,
		SIGNAL(executionFailed(int)),
		m_editor,
		SLOT(handleApplicationExit(int))
	);

	connect(
		m_interpreter,
		SIGNAL(finished()),
		SLOT(testFinished())
	);
	connect(
		m_interpreter,
		SIGNAL(startApplicationAndAttach()),
		SLOT(startApplication())
	);

	connect(
		m_quit,
		SIGNAL(triggered()),
		qApp,
		SLOT(quit())
	);

	connect(
		m_aboutQt,
		SIGNAL(triggered()),
		qApp,
		SLOT(aboutQt())
	);

	connect(
		m_about,
		SIGNAL(triggered()),
		SLOT(about())
	);

	ColumnClickMapper* mapper = new ColumnClickMapper(m_testList);
	mapper->addMapping(1, this, SLOT(runTestScript(QModelIndex)));
	mapper->addMapping(2, this, SLOT(editTestScript(QModelIndex)));

	updateActionStates();
}
Пример #3
0
w_int loadSuperClasses(w_clazz clazz, w_thread thread) {
  w_clazz super;
  w_int   i;
  w_int   n;
  w_int   result = CLASS_LOADING_DID_NOTHING;

#ifndef NO_FORMAT_CHECKS
  if (isNotSet(clazz->flags, CLAZZ_IS_TRUSTED) && !clazz->temp.super_index) {
    throwException(thread, clazzVerifyError, "Class %k has no superclass", clazz);

    return CLASS_LOADING_FAILED;
  }
#endif

  clazz->supers = allocMem(MAX_SUPER_CLASSES * sizeof(w_clazz));
  if (!clazz->supers) {
    return CLASS_LOADING_FAILED;
  }
  super = clazz;
  n = MAX_SUPER_CLASSES;
  for (i = 0; i < MAX_SUPER_CLASSES; ++i) {
    if (!super->temp.super_index) {
      woempa(1, "Reached top of hierarchy after %d class(es): %k\n", i, super);
      n = i;
      break;
    }

#ifndef NO_FORMAT_CHECKS
    if (isNotSet(super->flags, CLAZZ_IS_TRUSTED) && !isClassConstant(super, super->temp.super_index)) {
      throwException(thread, clazzClassFormatError, "Superclass of %k is not a class constant (is %02x)", super, super->tags[super->temp.super_index]);

      return CLASS_LOADING_FAILED;

    }
#endif

    super = getClassConstant(super, super->temp.super_index, thread);
    if (!super) {
      throwException(thread, clazzLinkageError, "Cannot resolve superclass of %k", clazz);

      return CLASS_LOADING_FAILED;

    }

    clazz->supers[i] = super;
    woempa(1, "Class %k supers[%d] = %k\n", clazz, i, super);
    if (getClazzState(super) >= CLAZZ_STATE_SUPERS_LOADED) {
      woempa(1, "Class %k is already supersLoaded, has %d superclasses => depth of %k is %d\n", super, super->numSuperClasses, clazz, i + super->numSuperClasses + 1);
      n = i + super->numSuperClasses + 1;
      break;
    }
  }

  if (n == MAX_SUPER_CLASSES) {
      wabort(ABORT_WONKA, "Class %k has too many superclasses", clazz);
  }

  for (i= i + 1; i < n; ++i) {
    woempa(1, "Copying %k (superclass[%d] of %k) as superclass[%d] of %k\n", super->supers[i - n + super->numSuperClasses], i - n + super->numSuperClasses, super, i, clazz);
    clazz->supers[i] = super->supers[i - n + super->numSuperClasses];
  }

  woempa(1, "Class %k has total of %d superclasses\n", clazz, n);
  clazz->supers = reallocMem(clazz->supers, n * sizeof(w_clazz));
  if (!clazz->supers) {
    return CLASS_LOADING_FAILED;
  }
  clazz->numSuperClasses = n;
  super = clazz->supers[0];
#ifndef NO_HIERARCHY_CHECKS
  if (isNotSet(super->flags, CLAZZ_IS_TRUSTED)) {
    if (isSet(clazz->flags, ACC_INTERFACE) && super != clazzObject) {
      throwException(thread, clazzIncompatibleClassChangeError, "Superclass %k of %k is an interface", super, clazz);

      return CLASS_LOADING_FAILED;

    }
    if (isSet(super->flags, ACC_FINAL)) {
      woempa(9, "Violation of J+JVM Constraint 4.1.1, item 2\n");
      throwException(thread, clazzIncompatibleClassChangeError, "Superclass %k of %k is final", super, clazz);

      return CLASS_LOADING_FAILED;

    }
    if (isNotSet(super->flags, ACC_PUBLIC) && !sameRuntimePackage(clazz, super)) {
      woempa(9, "Violation of J+JVM Constraint 4.1.4\n");
      throwException(thread, clazzIncompatibleClassChangeError, "Superclass %k of %k is not accessible", super, clazz);

      return CLASS_LOADING_FAILED;

    }
  }
#endif

  for (i = n - 1; i >= 0; --i) {
    result |= mustBeSupersLoaded(clazz->supers[i]);
    if (result == CLASS_LOADING_FAILED || exceptionThrown(thread)) {

      return CLASS_LOADING_FAILED;

    }
  }

  clazz->flags |= super->flags & CLAZZ_HERITABLE_FLAGS;

  return CLASS_LOADING_SUCCEEDED;
}