@JavascriptEnabled
  @Ignore(
      value = {SAFARI, MARIONETTE},
      reason = " Safari: issue 4061. Other platforms: not properly tested")
  @Test
  public void testChangeEventIsFiredAppropriatelyWhenFocusIsLost() {
    driver.get(pages.javascriptPage);

    WebElement input = driver.findElement(By.id("changeable"));
    input.sendKeys("test");
    moveFocus();
    assertThat(
        driver.findElement(By.id("result")).getText().trim(),
        Matchers.<String>either(is("focus change blur")).or(is("focus blur change")));

    input.sendKeys(Keys.BACK_SPACE, "t");
    moveFocus();

    // I weep.
    assertThat(
        driver.findElement(By.id("result")).getText().trim(),
        Matchers.<String>either(is("focus change blur focus blur"))
            .or(is("focus blur change focus blur"))
            .or(is("focus blur change focus blur change"))
            .or(is("focus change blur focus change blur"))); // What Chrome does
  }
Пример #2
0
  @Before
  public void setUp() throws Throwable {
    // Filter disabled tests
    assumeTrue(test.isEnabled());

    String fileContent = test.readFile();
    if (!test.isValidTest(isStrictTest, unmarkedDefault)) {
      return;
    }

    final String preamble;
    if (test.isRaw()) {
      preamble = "";
      preambleLines = 0;
    } else if (isStrictTest) {
      preamble = "\"use strict\";\nvar strict_mode = true;\n";
      preambleLines = 2;
    } else {
      preamble = "//\"use strict\";\nvar strict_mode = false;\n";
      preambleLines = 2;
    }
    sourceCode = Strings.concat(preamble, fileContent);

    global = globals.newGlobal(new Test262Console(), test);
    exceptionHandler.setExecutionContext(global.getRealm().defaultContext());

    if (!test.isNegative()) {
      errorHandler.match(StandardErrorHandler.defaultMatcher());
      exceptionHandler.match(ScriptExceptionHandler.defaultMatcher());
    } else {
      expected.expect(
          Matchers.either(StandardErrorHandler.defaultMatcher())
              .or(ScriptExceptionHandler.defaultMatcher())
              .or(instanceOf(Test262AssertionError.class)));
      String errorType = test.getErrorType();
      if (errorType != null) {
        expected.expect(
            hasErrorMessage(
                global.getRealm().defaultContext(),
                matchesPattern(errorType, Pattern.CASE_INSENSITIVE)));
      }
    }

    // Load test includes
    for (String name : test.getIncludes()) {
      global.include(name);
    }

    if (test.isAsync()) {
      // "doneprintHandle.js" is replaced with AsyncHelper
      async = global.install(new AsyncHelper(), AsyncHelper.class);
    }

    // Install test hooks
    if (!test.getScript().startsWith(selfTestDirectory)) {
      global.install(global, Test262GlobalObject.class);
    }
  }
  @Test
  public void shouldFireEventForRelationshipEntities() throws Exception {
    FictionalCharacter beleg = template.save(new FictionalCharacter("Beleg"));
    FictionalCharacter brandir = template.save(new FictionalCharacter("Brandir"));
    entities.clear();
    FictionalCharacter turin = new FictionalCharacter("Túrin");
    turin.slew(beleg, brandir);

    template.save(turin);

    assertThat(entities.size(), is(3));
    assertThat(((FictionalCharacter) entities.get(0)).id, is(turin.id));
    assertThat(
        ((Slaying) entities.get(1)).slayee.id,
        is(Matchers.<Long>either(equalTo(beleg.id)).or(equalTo(brandir.id))));
    assertThat(
        ((Slaying) entities.get(2)).slayee.id,
        is(Matchers.<Long>either(equalTo(beleg.id)).or(equalTo(brandir.id))));
  }
Пример #4
0
  @Before
  public void setUp() throws Throwable {
    assumeTrue("Test disabled", test.isEnabled());

    String fileContent = test.readFile();
    if (!isValidTestConfiguration()) {
      return;
    }

    final String preamble;
    if (test.isRaw() || test.isModule()) {
      preamble = "";
      preambleLines = 0;
    } else if (isStrictTest) {
      preamble = "\"use strict\";\nvar strict_mode = true;\n";
      preambleLines = 2;
    } else {
      preamble = "//\"use strict\";\nvar strict_mode = false;\n";
      preambleLines = 2;
    }
    sourceCode = Strings.concat(preamble, fileContent);

    global = globals.newGlobal(new Test262Console(), test);
    exceptionHandler.setExecutionContext(global.getRealm().defaultContext());

    if (!test.isNegative()) {
      errorHandler.match(StandardErrorHandler.defaultMatcher());
      exceptionHandler.match(ScriptExceptionHandler.defaultMatcher());
    } else {
      expected.expect(
          Matchers.either(StandardErrorHandler.defaultMatcher())
              .or(ScriptExceptionHandler.defaultMatcher()));
      String errorType = test.getErrorType();
      if (errorType != null) {
        expected.expect(
            hasErrorMessage(
                global.getRealm().defaultContext(),
                matchesPattern(errorType, Pattern.CASE_INSENSITIVE)));
      }
    }

    // Load test includes
    for (String name : test.getIncludes()) {
      global.include(name);
    }

    if (test.isAsync()) {
      async = global.install(new Test262Async(), Test262Async.class);
    }
  }