content/renderer/browser_plugin/browser_plugin_browsertest.cc
// This test verifies that BrowserPlugin enters an error state when the
// partition attribute is invalid.
This test verifies that BrowserPlugin enters an error state when the
partition attribute is invalid.
This test verifies that BrowserPlugin enters an error state when the partition attribute is invalid .
TEST_F(BrowserPluginTest, InvalidPartition) {
  std::string html = StringPrintf(kHTMLForInvalidPartitionedPluginObject,
                                  content::kBrowserPluginMimeType);
  LoadHTML(html.c_str());
  {
    ExecuteJavaScript(
        "try {"
        "  document.getElementById('browserplugin').src = 'bar';"
        "  document.title = 'success';"
        "} catch (e) { document.title = e.message; }");
    std::string title = ExecuteScriptAndReturnString("document.title");
    EXPECT_STREQ("Invalid partition attribute.", title.c_str());
    EXPECT_EQ("", ExecuteScriptAndReturnString(
        "document.getElementById('browserplugin').src"));
  }
  ExecuteJavaScript(
      "document.getElementById('browserplugin').partition = 'persist:foo'");
  ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'");
  EXPECT_EQ("bar", ExecuteScriptAndReturnString(
      "document.getElementById('browserplugin').src"));
  {
    ExecuteJavaScript(
        "try {"
        "  document.getElementById('browserplugin').partition = 'persist:1337';"
        "  document.title = 'success';"
        "} catch (e) { document.title = e.message; }");
    std::string title = ExecuteScriptAndReturnString("document.title");
    EXPECT_STREQ(
        "The object has already navigated, so its partition cannot be changed.",
        title.c_str());
    ExecuteJavaScript("document.getElementById('browserplugin').src = '42'");
    EXPECT_EQ("42", ExecuteScriptAndReturnString(
        "document.getElementById('browserplugin').src"));
  }
}
TEST_F ( BrowserPluginTest , InvalidPartition ) { std :: string html = StringPrintf ( kHTMLForInvalidPartitionedPluginObject , content :: kBrowserPluginMimeType ) ; LoadHTML ( html . c_str ( ) ) ; { ExecuteJavaScript ( " " " " " " " " ) ; std :: string title = ExecuteScriptAndReturnString ( " " ) ; EXPECT_STREQ ( " " , title . c_str ( ) ) ; EXPECT_EQ ( " " , ExecuteScriptAndReturnString ( " " ) ) ; } ExecuteJavaScript ( " " ) ; ExecuteJavaScript ( " " ) ; EXPECT_EQ ( " " , ExecuteScriptAndReturnString ( " " ) ) ; { ExecuteJavaScript ( " " " " " " " " ) ; std :: string title = ExecuteScriptAndReturnString ( " " ) ; EXPECT_STREQ ( " " , title . c_str ( ) ) ; ExecuteJavaScript ( " " ) ; EXPECT_EQ ( " " , ExecuteScriptAndReturnString ( " " ) ) ; } }
This test verifies that BrowserPlugin enters an error state when the
partition attribute is invalid.
This test verifies that BrowserPlugin enters an error state when the partition attribute is invalid .
// Attempt to navigate with an invalid partition. // Verify that the 'src' attribute has not been updated. // Verify that the BrowserPlugin accepts changes to its src attribue after // setting the partition to a valid value. // Verify that the BrowserPlugin does not 'deadlock': it can recover from // the partition ID error state.